Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Package Functions | List of all members
io.flutter.embedding.engine.FlutterEngine Class Reference
Inheritance diagram for io.flutter.embedding.engine.FlutterEngine:
io.flutter.util.ViewUtils.DisplayUpdater

Classes

interface  EngineLifecycleListener
 

Public Member Functions

 FlutterEngine (@NonNull Context context)
 
 FlutterEngine (@NonNull Context context, @Nullable String[] dartVmArgs)
 
 FlutterEngine ( @NonNull Context context, @Nullable String[] dartVmArgs, boolean automaticallyRegisterPlugins)
 
 FlutterEngine ( @NonNull Context context, @Nullable String[] dartVmArgs, boolean automaticallyRegisterPlugins, boolean waitForRestorationData)
 
 FlutterEngine ( @NonNull Context context, @Nullable FlutterLoader flutterLoader, @NonNull FlutterJNI flutterJNI)
 
 FlutterEngine ( @NonNull Context context, @Nullable FlutterLoader flutterLoader, @NonNull FlutterJNI flutterJNI, @Nullable String[] dartVmArgs, boolean automaticallyRegisterPlugins)
 
 FlutterEngine ( @NonNull Context context, @Nullable FlutterLoader flutterLoader, @NonNull FlutterJNI flutterJNI, @NonNull PlatformViewsController platformViewsController, @Nullable String[] dartVmArgs, boolean automaticallyRegisterPlugins)
 
 FlutterEngine ( @NonNull Context context, @Nullable FlutterLoader flutterLoader, @NonNull FlutterJNI flutterJNI, @NonNull PlatformViewsController platformViewsController, @Nullable String[] dartVmArgs, boolean automaticallyRegisterPlugins, boolean waitForRestorationData)
 
 FlutterEngine ( @NonNull Context context, @Nullable FlutterLoader flutterLoader, @NonNull FlutterJNI flutterJNI, @NonNull PlatformViewsController platformViewsController, @Nullable String[] dartVmArgs, boolean automaticallyRegisterPlugins, boolean waitForRestorationData, @Nullable FlutterEngineGroup group)
 
void destroy ()
 
void addEngineLifecycleListener (@NonNull EngineLifecycleListener listener)
 
void removeEngineLifecycleListener (@NonNull EngineLifecycleListener listener)
 
DartExecutor getDartExecutor ()
 
FlutterRenderer getRenderer ()
 
AccessibilityChannel getAccessibilityChannel ()
 
LifecycleChannel getLifecycleChannel ()
 
LocalizationChannel getLocalizationChannel ()
 
NavigationChannel getNavigationChannel ()
 
BackGestureChannel getBackGestureChannel ()
 
PlatformChannel getPlatformChannel ()
 
ProcessTextChannel getProcessTextChannel ()
 
RestorationChannel getRestorationChannel ()
 
SettingsChannel getSettingsChannel ()
 
DeferredComponentChannel getDeferredComponentChannel ()
 
SystemChannel getSystemChannel ()
 
MouseCursorChannel getMouseCursorChannel ()
 
TextInputChannel getTextInputChannel ()
 
SpellCheckChannel getSpellCheckChannel ()
 
PluginRegistry getPlugins ()
 
LocalizationPlugin getLocalizationPlugin ()
 
PlatformViewsController getPlatformViewsController ()
 
ActivityControlSurface getActivityControlSurface ()
 
ServiceControlSurface getServiceControlSurface ()
 
BroadcastReceiverControlSurface getBroadcastReceiverControlSurface ()
 
ContentProviderControlSurface getContentProviderControlSurface ()
 
void updateDisplayMetrics (float width, float height, float density)
 
void updateDisplayMetrics (float width, float height, float density)
 

Package Functions

FlutterEngine spawn ( @NonNull Context context, @NonNull DartEntrypoint dartEntrypoint, @Nullable String initialRoute, @Nullable List< String > dartEntrypointArgs, @Nullable PlatformViewsController platformViewsController, boolean automaticallyRegisterPlugins, boolean waitForRestorationData)
 

Detailed Description

A single Flutter execution environment.

The FlutterEngine is the container through which Dart code can be run in an Android application.

Dart code in a FlutterEngine can execute in the background, or it can be render to the screen by using the accompanying FlutterRenderer and Dart code using the Flutter framework on the Dart side. Rendering can be started and stopped, thus allowing a
FlutterEngine
to move from UI interaction to data-only processing and then back to UI interaction.

Multiple FlutterEngines may exist, execute Dart code, and render UIs within a single Android app. For better memory performance characteristics, construct multiple
FlutterEngine
s via io.flutter.embedding.engine.FlutterEngineGroup rather than via
FlutterEngine
's constructor directly.

To start running Dart and/or Flutter within this FlutterEngine, get a reference to this engine's DartExecutor and then use DartExecutor#executeDartEntrypoint(DartExecutor.DartEntrypoint). The DartExecutor#executeDartEntrypoint(DartExecutor.DartEntrypoint) method must not be invoked twice on the same FlutterEngine.

To start rendering Flutter content to the screen, use getRenderer() to obtain a FlutterRenderer and then attach a RenderSurface. Consider using a io.flutter.embedding.android.FlutterView as a RenderSurface.

Instatiating the first FlutterEngine per process will also load the Flutter engine's native library and start the Dart VM. Subsequent FlutterEngines will run on the same VM instance but will have their own Dart Isolate when the DartExecutor is run. Each Isolate is a self-contained Dart environment and cannot communicate with each other except via Isolate ports.

Definition at line 83 of file FlutterEngine.java.

Constructor & Destructor Documentation

◆ FlutterEngine() [1/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context)
inline

Constructs a new FlutterEngine.

A new FlutterEngine does not execute any Dart code automatically. See getDartExecutor() and DartExecutor#executeDartEntrypoint(DartExecutor.DartEntrypoint) to begin executing Dart code within this FlutterEngine.

A new FlutterEngine will not display any UI until a RenderSurface is registered. See getRenderer() and FlutterRenderer#startRenderingToSurface(Surface, boolean).

A new FlutterEngine automatically attaches all plugins. See getPlugins().

A new FlutterEngine does come with all default system channels attached.

The first FlutterEngine instance constructed per process will also load the Flutter native library and start a Dart VM.

In order to pass Dart VM initialization arguments (see io.flutter.embedding.engine.FlutterShellArgs) when creating the VM, manually set the initialization arguments by calling io.flutter.embedding.engine.loader.FlutterLoader#startInitialization(Context) and io.flutter.embedding.engine.loader.FlutterLoader#ensureInitializationComplete(Context, String[]) before constructing the engine.

Definition at line 160 of file FlutterEngine.java.

160 {
161 this(context, null);
162 }

◆ FlutterEngine() [2/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable String[]  dartVmArgs 
)
inline

Same as FlutterEngine(Context) with added support for passing Dart VM arguments.

If the Dart VM has already started, the given arguments will have no effect.

Definition at line 169 of file FlutterEngine.java.

169 {
170 this(context, /* flutterLoader */ null, /* flutterJNI */ null, dartVmArgs, true);
171 }

◆ FlutterEngine() [3/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable String[]  dartVmArgs,
boolean  automaticallyRegisterPlugins 
)
inline

Same as FlutterEngine(Context) with added support for passing Dart VM arguments and avoiding automatic plugin registration.

If the Dart VM has already started, the given arguments will have no effect.

Definition at line 179 of file FlutterEngine.java.

182 {
183 this(
184 context,
185 /* flutterLoader */ null,
186 /* flutterJNI */ null,
187 dartVmArgs,
188 automaticallyRegisterPlugins);
189 }

◆ FlutterEngine() [4/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable String[]  dartVmArgs,
boolean  automaticallyRegisterPlugins,
boolean  waitForRestorationData 
)
inline

Same as FlutterEngine(Context, String[], boolean) with added support for configuring whether the engine will receive restoration data.

The waitForRestorationData flag controls whether the engine delays responding to requests from the framework for restoration data until that data has been provided to the engine via RestorationChannel.setRestorationData(byte[] data). If the flag is false, the framework may temporarily initialize itself to default values before the restoration data has been made available to the engine. Setting waitForRestorationData to true avoids this extra work by delaying initialization until the data is available.

When waitForRestorationData is set,
RestorationChannel.setRestorationData(byte[] data)
must be called at a later point in time. If it later turns out that no restoration data is available to restore the framework from, that method must still be called with null as an argument to indicate "no data".

If the framework never requests the restoration data, this flag has no effect.

Definition at line 209 of file FlutterEngine.java.

213 {
214 this(
215 context,
216 /* flutterLoader */ null,
217 /* flutterJNI */ null,
218 new PlatformViewsController(),
219 dartVmArgs,
220 automaticallyRegisterPlugins,
221 waitForRestorationData);
222 }

◆ FlutterEngine() [5/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable FlutterLoader  flutterLoader,
@NonNull FlutterJNI  flutterJNI 
)
inline

Same as FlutterEngine(Context, FlutterLoader, FlutterJNI, String[], boolean) but with no Dart VM flags and automatically registers plugins.

flutterJNI should be a new instance that has never been attached to an engine before.

Definition at line 231 of file FlutterEngine.java.

234 {
235 this(context, flutterLoader, flutterJNI, null, true);
236 }

◆ FlutterEngine() [6/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable FlutterLoader  flutterLoader,
@NonNull FlutterJNI  flutterJNI,
@Nullable String[]  dartVmArgs,
boolean  automaticallyRegisterPlugins 
)
inline

Same as FlutterEngine(Context, FlutterLoader, FlutterJNI), plus Dart VM flags in dartVmArgs, and control over whether plugins are automatically registered with this FlutterEngine in automaticallyRegisterPlugins. If plugins are automatically registered, then they are registered during the execution of this constructor.

Definition at line 244 of file FlutterEngine.java.

249 {
250 this(
251 context,
252 flutterLoader,
253 flutterJNI,
254 new PlatformViewsController(),
255 dartVmArgs,
256 automaticallyRegisterPlugins);
257 }

◆ FlutterEngine() [7/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable FlutterLoader  flutterLoader,
@NonNull FlutterJNI  flutterJNI,
@NonNull PlatformViewsController  platformViewsController,
@Nullable String[]  dartVmArgs,
boolean  automaticallyRegisterPlugins 
)
inline

Same as FlutterEngine(Context, FlutterLoader, FlutterJNI, String[], boolean), plus the ability to provide a custom PlatformViewsController.

Definition at line 263 of file FlutterEngine.java.

269 {
270 this(
271 context,
272 flutterLoader,
273 flutterJNI,
274 platformViewsController,
275 dartVmArgs,
276 automaticallyRegisterPlugins,
277 false);
278 }

◆ FlutterEngine() [8/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable FlutterLoader  flutterLoader,
@NonNull FlutterJNI  flutterJNI,
@NonNull PlatformViewsController  platformViewsController,
@Nullable String[]  dartVmArgs,
boolean  automaticallyRegisterPlugins,
boolean  waitForRestorationData 
)
inline

Fully configurable FlutterEngine constructor.

Definition at line 281 of file FlutterEngine.java.

288 {
289 this(
290 context,
291 flutterLoader,
292 flutterJNI,
293 platformViewsController,
294 dartVmArgs,
295 automaticallyRegisterPlugins,
296 waitForRestorationData,
297 null);
298 }

◆ FlutterEngine() [9/9]

io.flutter.embedding.engine.FlutterEngine.FlutterEngine ( @NonNull Context  context,
@Nullable FlutterLoader  flutterLoader,
@NonNull FlutterJNI  flutterJNI,
@NonNull PlatformViewsController  platformViewsController,
@Nullable String[]  dartVmArgs,
boolean  automaticallyRegisterPlugins,
boolean  waitForRestorationData,
@Nullable FlutterEngineGroup  group 
)
inline

Definition at line 301 of file FlutterEngine.java.

309 {
310 AssetManager assetManager;
311 try {
312 assetManager = context.createPackageContext(context.getPackageName(), 0).getAssets();
313 } catch (NameNotFoundException e) {
314 assetManager = context.getAssets();
315 }
316
317 FlutterInjector injector = FlutterInjector.instance();
318
319 if (flutterJNI == null) {
320 flutterJNI = injector.getFlutterJNIFactory().provideFlutterJNI();
321 }
322 this.flutterJNI = flutterJNI;
323
324 this.dartExecutor = new DartExecutor(flutterJNI, assetManager);
325 this.dartExecutor.onAttachedToJNI();
326
327 DeferredComponentManager deferredComponentManager =
328 FlutterInjector.instance().deferredComponentManager();
329
330 accessibilityChannel = new AccessibilityChannel(dartExecutor, flutterJNI);
331 deferredComponentChannel = new DeferredComponentChannel(dartExecutor);
332 lifecycleChannel = new LifecycleChannel(dartExecutor);
333 localizationChannel = new LocalizationChannel(dartExecutor);
334 mouseCursorChannel = new MouseCursorChannel(dartExecutor);
335 navigationChannel = new NavigationChannel(dartExecutor);
336 backGestureChannel = new BackGestureChannel(dartExecutor);
337 platformChannel = new PlatformChannel(dartExecutor);
338 processTextChannel = new ProcessTextChannel(dartExecutor, context.getPackageManager());
339 restorationChannel = new RestorationChannel(dartExecutor, waitForRestorationData);
340 settingsChannel = new SettingsChannel(dartExecutor);
341 spellCheckChannel = new SpellCheckChannel(dartExecutor);
342 systemChannel = new SystemChannel(dartExecutor);
343 textInputChannel = new TextInputChannel(dartExecutor);
344
345 if (deferredComponentManager != null) {
346 deferredComponentManager.setDeferredComponentChannel(deferredComponentChannel);
347 }
348
349 this.localizationPlugin = new LocalizationPlugin(context, localizationChannel);
350
351 if (flutterLoader == null) {
352 flutterLoader = injector.flutterLoader();
353 }
354
355 if (!flutterJNI.isAttached()) {
356 flutterLoader.startInitialization(context.getApplicationContext());
357 flutterLoader.ensureInitializationComplete(context, dartVmArgs);
358 }
359
360 flutterJNI.addEngineLifecycleListener(engineLifecycleListener);
361 flutterJNI.setPlatformViewsController(platformViewsController);
362 flutterJNI.setLocalizationPlugin(localizationPlugin);
363 flutterJNI.setDeferredComponentManager(injector.deferredComponentManager());
364
365 // It should typically be a fresh, unattached JNI. But on a spawned engine, the JNI instance
366 // is already attached to a native shell. In that case, the Java FlutterEngine is created around
367 // an existing shell.
368 if (!flutterJNI.isAttached()) {
369 attachToJni();
370 }
371
372 // TODO(mattcarroll): FlutterRenderer is temporally coupled to attach(). Remove that coupling if
373 // possible.
374 this.renderer = new FlutterRenderer(flutterJNI);
375
376 this.platformViewsController = platformViewsController;
377 this.platformViewsController.onAttachedToJNI();
378
379 this.pluginRegistry =
380 new FlutterEngineConnectionRegistry(
381 context.getApplicationContext(), this, flutterLoader, group);
382
383 localizationPlugin.sendLocalesToFlutter(context.getResources().getConfiguration());
384
385 // Only automatically register plugins if both constructor parameter and
386 // loaded AndroidManifest config turn this feature on.
387 if (automaticallyRegisterPlugins && flutterLoader.automaticallyRegisterPlugins()) {
388 GeneratedPluginRegister.registerGeneratedPlugins(this);
389 }
390
391 ViewUtils.calculateMaximumDisplayMetrics(context, this);
392
393 ProcessTextPlugin processTextPlugin = new ProcessTextPlugin(this.getProcessTextChannel());
394 this.pluginRegistry.add(processTextPlugin);
395 }
void setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
void setPlatformViewsController(@NonNull PlatformViewsController platformViewsController)
void addEngineLifecycleListener(@NonNull EngineLifecycleListener engineLifecycleListener)
void setLocalizationPlugin(@Nullable LocalizationPlugin localizationPlugin)
void sendLocalesToFlutter(@NonNull Configuration config)

Member Function Documentation

◆ addEngineLifecycleListener()

void io.flutter.embedding.engine.FlutterEngine.addEngineLifecycleListener ( @NonNull EngineLifecycleListener  listener)
inline

Adds a listener to be notified of Flutter engine lifecycle events, e.g.,
onPreEngineStart()
.

Definition at line 486 of file FlutterEngine.java.

486 {
487 engineLifecycleListeners.add(listener);
488 }

◆ destroy()

void io.flutter.embedding.engine.FlutterEngine.destroy ( )
inline

Cleans up all components within this FlutterEngine and destroys the associated Dart Isolate. All state held by the Dart Isolate, such as the Flutter Elements tree, is lost.

This FlutterEngine instance should be discarded after invoking this method.

Definition at line 464 of file FlutterEngine.java.

464 {
465 Log.v(TAG, "Destroying.");
466 for (EngineLifecycleListener listener : engineLifecycleListeners) {
467 listener.onEngineWillDestroy();
468 }
469 // The order that these things are destroyed is important.
470 pluginRegistry.destroy();
471 platformViewsController.onDetachedFromJNI();
472 dartExecutor.onDetachedFromJNI();
473 flutterJNI.removeEngineLifecycleListener(engineLifecycleListener);
474 flutterJNI.setDeferredComponentManager(null);
476 if (FlutterInjector.instance().deferredComponentManager() != null) {
477 FlutterInjector.instance().deferredComponentManager().destroy();
478 deferredComponentChannel.setDeferredComponentManager(null);
479 }
480 }
void removeEngineLifecycleListener( @NonNull EngineLifecycleListener engineLifecycleListener)
void setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
void Log(const char *format,...) SK_PRINTF_LIKE(1
Definition: TestRunner.cpp:137

◆ getAccessibilityChannel()

AccessibilityChannel io.flutter.embedding.engine.FlutterEngine.getAccessibilityChannel ( )
inline

System channel that sends accessibility requests and events from Flutter to Android.

Definition at line 525 of file FlutterEngine.java.

525 {
526 return accessibilityChannel;
527 }

◆ getActivityControlSurface()

ActivityControlSurface io.flutter.embedding.engine.FlutterEngine.getActivityControlSurface ( )
inline

Definition at line 643 of file FlutterEngine.java.

643 {
644 return pluginRegistry;
645 }

◆ getBackGestureChannel()

BackGestureChannel io.flutter.embedding.engine.FlutterEngine.getBackGestureChannel ( )
inline

System channel that sends back gesture commands from Android to Flutter.

Definition at line 549 of file FlutterEngine.java.

549 {
550 return backGestureChannel;
551 }

◆ getBroadcastReceiverControlSurface()

BroadcastReceiverControlSurface io.flutter.embedding.engine.FlutterEngine.getBroadcastReceiverControlSurface ( )
inline

Definition at line 653 of file FlutterEngine.java.

653 {
654 return pluginRegistry;
655 }

◆ getContentProviderControlSurface()

ContentProviderControlSurface io.flutter.embedding.engine.FlutterEngine.getContentProviderControlSurface ( )
inline

Definition at line 658 of file FlutterEngine.java.

658 {
659 return pluginRegistry;
660 }

◆ getDartExecutor()

DartExecutor io.flutter.embedding.engine.FlutterEngine.getDartExecutor ( )
inline

The Dart execution context associated with this FlutterEngine.

The DartExecutor can be used to start executing Dart code from a given entrypoint. See DartExecutor#executeDartEntrypoint(DartExecutor.DartEntrypoint).

Use the DartExecutor to connect any desired message channels and method channels to facilitate communication between Android and Dart/Flutter.

Definition at line 508 of file FlutterEngine.java.

508 {
509 return dartExecutor;
510 }

◆ getDeferredComponentChannel()

DeferredComponentChannel io.flutter.embedding.engine.FlutterEngine.getDeferredComponentChannel ( )
inline

System channel that allows manual installation and state querying of deferred components.

Definition at line 591 of file FlutterEngine.java.

591 {
592 return deferredComponentChannel;
593 }

◆ getLifecycleChannel()

LifecycleChannel io.flutter.embedding.engine.FlutterEngine.getLifecycleChannel ( )
inline

System channel that sends Android lifecycle events to Flutter.

Definition at line 531 of file FlutterEngine.java.

531 {
532 return lifecycleChannel;
533 }

◆ getLocalizationChannel()

LocalizationChannel io.flutter.embedding.engine.FlutterEngine.getLocalizationChannel ( )
inline

System channel that sends locale data from Android to Flutter.

Definition at line 537 of file FlutterEngine.java.

537 {
538 return localizationChannel;
539 }

◆ getLocalizationPlugin()

LocalizationPlugin io.flutter.embedding.engine.FlutterEngine.getLocalizationPlugin ( )
inline

The LocalizationPlugin this FlutterEngine created.

Definition at line 629 of file FlutterEngine.java.

629 {
630 return localizationPlugin;
631 }

◆ getMouseCursorChannel()

MouseCursorChannel io.flutter.embedding.engine.FlutterEngine.getMouseCursorChannel ( )
inline

System channel that sends and receives text input requests and state.

Definition at line 603 of file FlutterEngine.java.

603 {
604 return mouseCursorChannel;
605 }

◆ getNavigationChannel()

NavigationChannel io.flutter.embedding.engine.FlutterEngine.getNavigationChannel ( )
inline

System channel that sends Flutter navigation commands from Android to Flutter.

Definition at line 543 of file FlutterEngine.java.

543 {
544 return navigationChannel;
545 }

◆ getPlatformChannel()

PlatformChannel io.flutter.embedding.engine.FlutterEngine.getPlatformChannel ( )
inline

System channel that sends platform-oriented requests and information to Flutter, e.g., requests to play sounds, requests for haptics, system chrome settings, etc.

Definition at line 558 of file FlutterEngine.java.

558 {
559 return platformChannel;
560 }

◆ getPlatformViewsController()

PlatformViewsController io.flutter.embedding.engine.FlutterEngine.getPlatformViewsController ( )
inline

PlatformViewsController, which controls all platform views running within this
FlutterEngine
.

Definition at line 638 of file FlutterEngine.java.

638 {
639 return platformViewsController;
640 }

◆ getPlugins()

PluginRegistry io.flutter.embedding.engine.FlutterEngine.getPlugins ( )
inline

Plugin registry, which registers plugins that want to be applied to this FlutterEngine.

Definition at line 623 of file FlutterEngine.java.

623 {
624 return pluginRegistry;
625 }

◆ getProcessTextChannel()

ProcessTextChannel io.flutter.embedding.engine.FlutterEngine.getProcessTextChannel ( )
inline

System channel that sends text processing requests from Flutter to Android.

Definition at line 564 of file FlutterEngine.java.

564 {
565 return processTextChannel;
566 }

◆ getRenderer()

FlutterRenderer io.flutter.embedding.engine.FlutterEngine.getRenderer ( )
inline

The rendering system associated with this FlutterEngine.

To render a Flutter UI that is produced by this FlutterEngine's Dart code, attach a RenderSurface to this FlutterRenderer.

Definition at line 519 of file FlutterEngine.java.

519 {
520 return renderer;
521 }

◆ getRestorationChannel()

RestorationChannel io.flutter.embedding.engine.FlutterEngine.getRestorationChannel ( )
inline

System channel to exchange restoration data between framework and engine.

The engine can obtain the current restoration data from the framework via this channel to store it on disk and - when the app is relaunched - provide the stored data back to the framework to recreate the original state of the app.

Definition at line 576 of file FlutterEngine.java.

576 {
577 return restorationChannel;
578 }

◆ getServiceControlSurface()

ServiceControlSurface io.flutter.embedding.engine.FlutterEngine.getServiceControlSurface ( )
inline

Definition at line 648 of file FlutterEngine.java.

648 {
649 return pluginRegistry;
650 }

◆ getSettingsChannel()

SettingsChannel io.flutter.embedding.engine.FlutterEngine.getSettingsChannel ( )
inline

System channel that sends platform/user settings from Android to Flutter, e.g., time format, scale factor, etc.

Definition at line 585 of file FlutterEngine.java.

585 {
586 return settingsChannel;
587 }

◆ getSpellCheckChannel()

SpellCheckChannel io.flutter.embedding.engine.FlutterEngine.getSpellCheckChannel ( )
inline

System channel that sends and receives spell check requests and results.

Definition at line 615 of file FlutterEngine.java.

615 {
616 return spellCheckChannel;
617 }

◆ getSystemChannel()

SystemChannel io.flutter.embedding.engine.FlutterEngine.getSystemChannel ( )
inline

System channel that sends memory pressure warnings from Android to Flutter.

Definition at line 597 of file FlutterEngine.java.

597 {
598 return systemChannel;
599 }

◆ getTextInputChannel()

TextInputChannel io.flutter.embedding.engine.FlutterEngine.getTextInputChannel ( )
inline

System channel that sends and receives text input requests and state.

Definition at line 609 of file FlutterEngine.java.

609 {
610 return textInputChannel;
611 }

◆ removeEngineLifecycleListener()

void io.flutter.embedding.engine.FlutterEngine.removeEngineLifecycleListener ( @NonNull EngineLifecycleListener  listener)
inline

Removes a listener that was previously added with addEngineLifecycleListener(EngineLifecycleListener).

Definition at line 494 of file FlutterEngine.java.

494 {
495 engineLifecycleListeners.remove(listener);
496 }

◆ spawn()

FlutterEngine io.flutter.embedding.engine.FlutterEngine.spawn ( @NonNull Context  context,
@NonNull DartEntrypoint  dartEntrypoint,
@Nullable String  initialRoute,
@Nullable List< String >  dartEntrypointArgs,
@Nullable PlatformViewsController  platformViewsController,
boolean  automaticallyRegisterPlugins,
boolean  waitForRestorationData 
)
inlinepackage

Create a second io.flutter.embedding.engine.FlutterEngine based on this current one by sharing as much resources together as possible to minimize startup latency and memory cost.

Parameters
contextis a Context used to create the io.flutter.embedding.engine.FlutterEngine. Could be the same Context as the current engine or a different one. Generally, only an application Context is needed for the io.flutter.embedding.engine.FlutterEngine and its dependencies.
dartEntrypointspecifies the DartEntrypoint the new engine should run. It doesn't need to be the same entrypoint as the current engine but must be built in the same AOT or snapshot.
initialRouteThe name of the initial Flutter Navigator Route to load. If this is null, it will default to the "/" route.
dartEntrypointArgsArguments passed as a list of string to Dart's entrypoint function.
Returns
a new io.flutter.embedding.engine.FlutterEngine.

Definition at line 428 of file FlutterEngine.java.

435 {
436 if (!isAttachedToJni()) {
437 throw new IllegalStateException(
438 "Spawn can only be called on a fully constructed FlutterEngine");
439 }
440
441 FlutterJNI newFlutterJNI =
442 flutterJNI.spawn(
443 dartEntrypoint.dartEntrypointFunctionName,
444 dartEntrypoint.dartEntrypointLibrary,
445 initialRoute,
446 dartEntrypointArgs);
447 return new FlutterEngine(
448 context, // Context.
449 null, // FlutterLoader. A null value passed here causes the constructor to get it from the
450 // FlutterInjector.
451 newFlutterJNI, // FlutterJNI.
452 platformViewsController, // PlatformViewsController.
453 null, // String[]. The Dart VM has already started, this arguments will have no effect.
454 automaticallyRegisterPlugins, // boolean.
455 waitForRestorationData); // boolean
456 }
FlutterJNI spawn( @Nullable String entrypointFunctionName, @Nullable String pathToEntrypointFunction, @Nullable String initialRoute, @Nullable List< String > entrypointArgs)

◆ updateDisplayMetrics()

void io.flutter.embedding.engine.FlutterEngine.updateDisplayMetrics ( float  width,
float  height,
float  density 
)
inline

Publishes display metrics to Dart code in Flutter.

Implements io.flutter.util.ViewUtils.DisplayUpdater.

Definition at line 675 of file FlutterEngine.java.

675 {
676 flutterJNI.updateDisplayMetrics(0 /* display ID */, width, height, density);
677 }
void updateDisplayMetrics(int displayId, float width, float height, float density)
int32_t height
int32_t width

The documentation for this class was generated from the following file: