Flutter Engine
The Flutter Engine
|
The FlutterActivity
or FlutterFragment
that owns this
.
FlutterActivityAndFragmentDelegate
Definition at line 1051 of file FlutterActivityAndFragmentDelegate.java.
boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.attachToEngineAutomatically | ( | ) |
Whether to automatically attach the FlutterView
to the engine.
In the add-to-app scenario where multiple FlutterView
share the same FlutterEngine
, the host application desires to determine the timing of attaching the FlutterView
to the engine, for example, during the onResume
instead of the
.
onCreateView
Defaults to true
.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.cleanUpFlutterEngine | ( | @NonNull FlutterEngine | flutterEngine | ) |
Hook for the host to cleanup references that were established in configureFlutterEngine(FlutterEngine)
before the host is destroyed or detached.
Implements io.flutter.embedding.android.FlutterEngineConfigurator.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.configureFlutterEngine | ( | @NonNull FlutterEngine | flutterEngine | ) |
Hook for the host to configure the io.flutter.embedding.engine.FlutterEngine
as desired.
Implements io.flutter.embedding.android.FlutterEngineConfigurator.
Implemented in io.flutter.embedding.android.FlutterActivity, io.flutter.embedding.android.FlutterFragment, dev.flutter.scenarios.PlatformViewsActivity, and dev.flutter.scenarios.TestableFlutterActivity.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.detachFromFlutterEngine | ( | ) |
Callback called when the io.flutter.embedding.engine.FlutterEngine
has been attached to by another activity before this activity was destroyed.
The expected behavior is for this activity to synchronously stop using the FlutterEngine
to avoid lifecycle crosstalk with the new activity.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
Activity io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getActivity | ( | ) |
Returns the host android.app.Activity
or the Activity
that is currently attached to the host Fragment
.
Implemented in io.flutter.embedding.android.FlutterActivity.
String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getAppBundlePath | ( | ) |
Returns the path to the app bundle where the Dart code exists.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getCachedEngineGroupId | ( | ) |
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getCachedEngineId | ( | ) |
Returns the ID of a statically cached io.flutter.embedding.engine.FlutterEngine
to use within this delegate's host, or null
if this delegate's host does not want to use a cached FlutterEngine
.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
Context io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getContext | ( | ) |
Returns the Context
that backs the host android.app.Activity
or
.
Fragment
Implemented in io.flutter.embedding.android.FlutterActivity.
List< String > io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getDartEntrypointArgs | ( | ) |
Returns arguments that passed as a list of string to Dart's entrypoint function.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getDartEntrypointFunctionName | ( | ) |
Returns the Dart entrypoint that should run when a new io.flutter.embedding.engine.FlutterEngine
is created.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getDartEntrypointLibraryUri | ( | ) |
Returns the URI of the Dart library which contains the entrypoint method (example "package:foo_package/main.dart"). If null, this will default to the same library as the main()
function in the Dart program.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
ExclusiveAppComponent< Activity > io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getExclusiveAppComponent | ( | ) |
Returns the ExclusiveAppComponent<Activity>
that is associated with io.flutter.embedding.engine.FlutterEngine
.
In the scenario where multiple FlutterActivity
or FlutterFragment
share the same FlutterEngine
, to attach/re-attache a FlutterActivity
or FlutterFragment
to the shared FlutterEngine
, we MUST manually invoke ActivityControlSurface#attachToActivity(ExclusiveAppComponent, Lifecycle)
.
The ExclusiveAppComponent
is exposed here so that subclasses of FlutterActivity
or FlutterFragment
can access it.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
FlutterShellArgs io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getFlutterShellArgs | ( | ) |
Returns the FlutterShellArgs
that should be used when initializing Flutter.
Implemented in io.flutter.embedding.android.FlutterActivity, io.flutter.embedding.android.FlutterFragment, and dev.flutter.scenarios.TestActivity.
String io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getInitialRoute | ( | ) |
Returns the initial route that Flutter renders.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
Lifecycle io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getLifecycle | ( | ) |
Returns the Lifecycle
that backs the host android.app.Activity
or
.
Fragment
Implemented in io.flutter.embedding.android.FlutterActivity.
RenderMode io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getRenderMode | ( | ) |
Returns the RenderMode
used by the FlutterView
that displays the FlutterEngine
's content.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
TransparencyMode io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.getTransparencyMode | ( | ) |
Returns the TransparencyMode
used by the FlutterView
that displays the FlutterEngine
's content.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterSurfaceViewCreated | ( | @NonNull FlutterSurfaceView | flutterSurfaceView | ) |
Invoked by this delegate when the FlutterSurfaceView
that renders the Flutter UI is initially instantiated.
This method is only invoked if the io.flutter.embedding.android.FlutterView.RenderMode
is set to io.flutter.embedding.android.FlutterView.RenderMode#surface
. Otherwise, onFlutterTextureViewCreated(FlutterTextureView)
is invoked.
This method is invoked before the given FlutterSurfaceView
is attached to the View
hierarchy. Implementers should not attempt to climb the View
hierarchy or make assumptions about relationships with other View
s.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterTextureViewCreated | ( | @NonNull FlutterTextureView | flutterTextureView | ) |
Invoked by this delegate when the FlutterTextureView
that renders the Flutter UI is initially instantiated.
This method is only invoked if the io.flutter.embedding.android.FlutterView.RenderMode
is set to io.flutter.embedding.android.FlutterView.RenderMode#texture
. Otherwise, onFlutterSurfaceViewCreated(FlutterSurfaceView)
is invoked.
This method is invoked before the given FlutterTextureView
is attached to the View
hierarchy. Implementers should not attempt to climb the View
hierarchy or make assumptions about relationships with other View
s.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterUiDisplayed | ( | ) |
Invoked by this delegate when its FlutterView
starts painting pixels.
Implemented in io.flutter.embedding.android.FlutterActivity, io.flutter.embedding.android.FlutterFragment, dev.flutter.scenarios.ExternalTextureFlutterActivity, and dev.flutter.scenarios.TestActivity.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.onFlutterUiNoLongerDisplayed | ( | ) |
Invoked by this delegate when its FlutterView
stops painting pixels.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
FlutterEngine io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.provideFlutterEngine | ( | @NonNull Context | context | ) |
Returns the io.flutter.embedding.engine.FlutterEngine
that should be rendered to a FlutterView
.
If null
is returned, a new io.flutter.embedding.engine.FlutterEngine
will be created automatically.
Implements io.flutter.embedding.android.FlutterEngineProvider.
Implemented in io.flutter.embedding.android.FlutterActivity, io.flutter.embedding.android.FlutterFragment, io.flutter.embedding.android.FlutterActivityTest.FlutterActivityWithProvidedEngine, dev.flutter.scenarios.SpawnedEngineActivity, and dev.flutter.scenarios.SpawnMultiEngineActivity.
PlatformPlugin io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.providePlatformPlugin | ( | @Nullable Activity | activity, |
@NonNull FlutterEngine | flutterEngine | ||
) |
Hook for the host to create/provide a PlatformPlugin
if the associated Flutter experience should control system chrome.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldAttachEngineToActivity | ( | ) |
Returns true if the io.flutter.embedding.engine.FlutterEngine
's plugin system should be connected to the host android.app.Activity
, allowing plugins to interact with it.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldDestroyEngineWithHost | ( | ) |
Returns true if the io.flutter.embedding.engine.FlutterEngine
used in this delegate should be destroyed when the host/delegate are destroyed.
The default value is true
in cases where FlutterFragment
created its own io.flutter.embedding.engine.FlutterEngine
, and false
in cases where a cached io.flutter.embedding.engine.FlutterEngine
was provided.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldDispatchAppLifecycleState | ( | ) |
Give the host application a chance to take control of the app lifecycle events to avoid lifecycle crosstalk.
In the add-to-app scenario where multiple FlutterActivity
shares the same FlutterEngine
, the application lifecycle state will have crosstalk causing the page to freeze. For example, we open a new page called FlutterActivity#2 from the previous page called FlutterActivity#1. The flow of app lifecycle states received by dart is as follows:
inactive (from FlutterActivity#1) -> resumed (from FlutterActivity#2) -> paused (from FlutterActivity#1)
On the one hand, the paused
state from FlutterActivity#1 will cause the FlutterActivity#2 page to be stuck; On the other hand, these states are not expected from the perspective of the entire application lifecycle. If the host application gets the control of sending AppLifecycleState
, It will be possible to correctly match the AppLifecycleState
with the application-level lifecycle.
Return false
means the host application dispatches these app lifecycle events, while return true
means the engine dispatches these events.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldHandleDeeplinking | ( | ) |
Returns true if the delegate should retrieve the initial route from the Intent
.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
boolean io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.shouldRestoreAndSaveState | ( | ) |
Whether state restoration is enabled.
When this returns true, the instance state provided to
will be forwarded to the framework via the
onRestoreInstanceState(Bundle)
and during
RestorationChannelonSaveInstanceState(Bundle)
the current framework instance state obtained from RestorationChannel
will be stored in the provided bundle.
This defaults to true, unless a cached engine is used.
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.
void io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host.updateSystemUiOverlays | ( | ) |
Refreshes Android's window system UI (AKA system chrome) to match Flutter's desired system chrome style.
This is useful when using the splash screen API available in Android 12.
resets the system UI colors to the values set prior to the execution of the Dart entrypoint. As a result, the values set from Dart are reverted by this API. To workaround this issue, call this method after removing the splash screen with
SplashScreenView#remove
.
SplashScreenView#remove
Implemented in io.flutter.embedding.android.FlutterActivity, and io.flutter.embedding.android.FlutterFragment.