Class FlutterFragment
- All Implemented Interfaces:
ComponentCallbacks
,ComponentCallbacks2
,View.OnCreateContextMenuListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.DelegateFactory
,FlutterEngineConfigurator
,FlutterEngineProvider
,PlatformPlugin.PlatformPluginDelegate
Fragment
which displays a Flutter UI that takes up all available Fragment
space.
Using a FlutterFragment
requires forwarding a number of calls from an Activity
to ensure that the internal Flutter app behaves as expected:
onPostResume()
onBackPressed()
onRequestPermissionsResult(int, String[], int[])
onNewIntent(Intent)
onUserLeaveHint()
onBackPressed()
does not need to be called through if the fragment is constructed by one
of the builders with shouldAutomaticallyHandleOnBackPressed(true)
.
Additionally, when starting an Activity
for a result from this Fragment
, be
sure to invoke Fragment.startActivityForResult(Intent, int)
rather than Activity.startActivityForResult(Intent, int)
. If the Activity
version of the
method is invoked then this Fragment
will never receive its Fragment.onActivityResult(int, int, Intent)
callback.
If convenient, consider using a FlutterActivity
instead of a FlutterFragment
to avoid the work of forwarding calls.
FlutterFragment
supports the use of an existing, cached FlutterEngine
. To use a cached FlutterEngine
, ensure that the FlutterEngine
is stored in FlutterEngineCache
and then use withCachedEngine(String)
to
build a FlutterFragment
with the cached FlutterEngine
's ID.
It is generally recommended to use a cached FlutterEngine
to avoid a momentary delay when initializing a new FlutterEngine
. The two exceptions to using a cached FlutterEngine
are:
- When
FlutterFragment
is in the firstActivity
displayed by the app, because pre-warming aFlutterEngine
would have no impact in this situation. - When you are unsure when/if you will need to display a Flutter experience.
The following illustrates how to pre-warm and cache a FlutterEngine
:
// Create and pre-warm a FlutterEngine.
FlutterEngineGroup group = new FlutterEngineGroup(context);
FlutterEngine flutterEngine = group.createAndRunDefaultEngine(context);
flutterEngine
.getDartExecutor()
.executeDartEntrypoint(DartEntrypoint.createDefault());
// Cache the pre-warmed FlutterEngine in the FlutterEngineCache.
FlutterEngineCache.getInstance().put("my_engine", flutterEngine);
If Flutter is needed in a location that can only use a View
, consider using a FlutterView
. Using a FlutterView
requires forwarding some calls from an
Activity
, as well as forwarding lifecycle calls from an Activity
or a Fragment
.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder that creates a newFlutterFragment
that uses a cachedFlutterEngine
witharguments
that correspond to the values set on thisBuilder
.static class
Builder that creates a newFlutterFragment
witharguments
that correspond to the values set on thisNewEngineFragmentBuilder
.static class
Builder that creates a newFlutterFragment
that uses a cachedFlutterEngineGroup
to create a newFlutterEngine
witharguments
that correspond to the values set on thisBuilder
.Nested classes/interfaces inherited from class androidx.fragment.app.Fragment
androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Path to Flutter's Dart code.protected static final String
protected static final String
The ID of aFlutterEngine
cached inFlutterEngineCache
that will be used within the createdFlutterFragment
.protected static final String
The Dart entrypoint method name that is executed upon initialization.protected static final String
The Dart entrypoint arguments that is executed upon initialization.protected static final String
The Dart entrypoint method's URI that is executed upon initialization.protected static final String
True if theFlutterEngine
in the createdFlutterFragment
should be destroyed when theFlutterFragment
is destroyed, false if theFlutterEngine
should outlive theFlutterFragment
.protected static final String
True if the framework state in the engine attached to this engine should be stored and restored when this fragment is created and destroyed.protected static final String
Flutter shell arguments.protected static final String
protected static final String
protected static final String
Whether the activity delegate should handle the deeplinking request.protected static final String
Initial Flutter route that is rendered in a Navigator widget.protected static final String
protected static final String
True if the fragment should receiveonBackPressed()
events automatically, without requiring an explicit activity call through.protected static final String
Whether to delay the Android drawing pass till after the Flutter UI has been displayed.static final int
The ID of theFlutterView
created by this activity.Fields inherited from class androidx.fragment.app.Fragment
mPreviousWho
Fields inherited from interface android.content.ComponentCallbacks2
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether to automatically attach theFlutterView
to the engine.void
cleanUpFlutterEngine
(FlutterEngine flutterEngine) Hook for the host to cleanup references that were established inconfigureFlutterEngine(FlutterEngine)
before the host is destroyed or detached.void
configureFlutterEngine
(FlutterEngine flutterEngine) Configures aFlutterEngine
after its creation.static FlutterFragment
Creates aFlutterFragment
with a default configuration.io.flutter.embedding.android.FlutterActivityAndFragmentDelegate
createDelegate
(io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host host) Default delegate factory that creates a simple FlutterActivityAndFragmentDelegate instance.void
A custom path to the bundle that contains this Flutter app's resources, e.g., Dart code snapshots.Returns the ID of a statically cachedFlutterEngineGroup
to use within thisFlutterFragment
, ornull
if thisFlutterFragment
does not want to use a cachedFlutterEngineGroup
.Returns the ID of a statically cachedFlutterEngine
to use within thisFlutterFragment
, ornull
if thisFlutterFragment
does not want to use a cachedFlutterEngine
.The Dart entrypoint arguments will be passed as a list of string to Dart's entrypoint function.Returns the name of the Dart method that thisFlutterFragment
should execute to start a Flutter app.Returns the library URI of the Dart method that thisFlutterFragment
should execute to start a Flutter app.Returns the Android App Component exclusively attached toFlutterEngine
.Hook for subclasses to obtain a reference to theFlutterEngine
that is owned by thisFlutterActivity
.FlutterActivityAndFragmentDelegate.Host
method that is used byFlutterActivityAndFragmentDelegate
to obtain Flutter shell arguments when initializing Flutter.Returns the initial route that should be rendered within Flutter, once the Flutter app starts.androidx.lifecycle.Lifecycle
void
onActivityResult
(int requestCode, int resultCode, Intent data) A result has been returned after an invocation ofFragment.startActivityForResult(Intent, int)
.void
void
The hardware back button was pressed.void
onCreateView
(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) void
void
onDetach()
void
onFlutterSurfaceViewCreated
(FlutterSurfaceView flutterSurfaceView) void
onFlutterTextureViewCreated
(FlutterTextureView flutterTextureView) void
Invoked after theFlutterView
within thisFlutterFragment
starts rendering pixels to the screen.void
Invoked after theFlutterView
within thisFlutterFragment
stops rendering pixels to the screen.void
onNewIntent
(Intent intent) A new Intent was received by theActivity
that currently owns thisFragment
.void
onPause()
void
void
onRequestPermissionsResult
(int requestCode, String[] permissions, int[] grantResults) The result of a permission request has been received.void
onResume()
void
onSaveInstanceState
(Bundle outState) void
onStart()
void
onStop()
void
onTrimMemory
(int level) Callback invoked when memory is low.void
TheActivity
that owns thisFragment
is about to go to the background as the result of a user's choice/action, i.e., not as the result of an OS decision.void
onViewCreated
(View view, Bundle savedInstanceState) boolean
Allow implementer to customize the behavior needed when the Flutter framework calls to pop the Android-side navigation stack.provideFlutterEngine
(Context context) Hook for subclasses to return aFlutterEngine
with whatever configuration is desired.providePlatformPlugin
(Activity activity, FlutterEngine flutterEngine) void
setFrameworkHandlesBack
(boolean frameworkHandlesBack) The Flutter application would or would not like to handle navigation pop events itself.boolean
boolean
Returns false if theFlutterEngine
within thisFlutterFragment
should outlive theFlutterFragment
, itself.boolean
Give the host application a chance to take control of the app lifecycle events.boolean
Whether to handle the deeplinking from theIntent
automatically if thegetInitialRoute
returns null.boolean
void
withCachedEngine
(String engineId) Returns aFlutterFragment.CachedEngineFragmentBuilder
to create aFlutterFragment
with a cachedFlutterEngine
inFlutterEngineCache
.Returns aFlutterFragment.NewEngineFragmentBuilder
to create aFlutterFragment
with a newFlutterEngine
and a desired engine configuration.withNewEngineInGroup
(String engineGroupId) Returns aFlutterFragment.NewEngineInGroupFragmentBuilder
to create aFlutterFragment
with a cachedFlutterEngineGroup
inFlutterEngineGroupCache
.Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getDefaultViewModelCreationExtras, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface android.content.ComponentCallbacks
onConfigurationChanged, onLowMemory
-
Field Details
-
FLUTTER_VIEW_ID
public static final int FLUTTER_VIEW_IDThe ID of theFlutterView
created by this activity.This ID can be used to lookup
FlutterView
in the Android view hierarchy. For more, seeView.findViewById(int)
. -
ARG_DART_ENTRYPOINT
The Dart entrypoint method name that is executed upon initialization.- See Also:
-
ARG_DART_ENTRYPOINT_URI
The Dart entrypoint method's URI that is executed upon initialization.- See Also:
-
ARG_DART_ENTRYPOINT_ARGS
The Dart entrypoint arguments that is executed upon initialization.- See Also:
-
ARG_INITIAL_ROUTE
Initial Flutter route that is rendered in a Navigator widget.- See Also:
-
ARG_HANDLE_DEEPLINKING
Whether the activity delegate should handle the deeplinking request.- See Also:
-
ARG_APP_BUNDLE_PATH
Path to Flutter's Dart code.- See Also:
-
ARG_SHOULD_DELAY_FIRST_ANDROID_VIEW_DRAW
Whether to delay the Android drawing pass till after the Flutter UI has been displayed.- See Also:
-
ARG_FLUTTER_INITIALIZATION_ARGS
Flutter shell arguments.- See Also:
-
ARG_FLUTTERVIEW_RENDER_MODE
- See Also:
-
ARG_FLUTTERVIEW_TRANSPARENCY_MODE
- See Also:
-
ARG_SHOULD_ATTACH_ENGINE_TO_ACTIVITY
- See Also:
-
ARG_CACHED_ENGINE_ID
The ID of aFlutterEngine
cached inFlutterEngineCache
that will be used within the createdFlutterFragment
.- See Also:
-
ARG_CACHED_ENGINE_GROUP_ID
- See Also:
-
ARG_DESTROY_ENGINE_WITH_FRAGMENT
True if theFlutterEngine
in the createdFlutterFragment
should be destroyed when theFlutterFragment
is destroyed, false if theFlutterEngine
should outlive theFlutterFragment
.- See Also:
-
ARG_ENABLE_STATE_RESTORATION
True if the framework state in the engine attached to this engine should be stored and restored when this fragment is created and destroyed.- See Also:
-
ARG_SHOULD_AUTOMATICALLY_HANDLE_ON_BACK_PRESSED
True if the fragment should receiveonBackPressed()
events automatically, without requiring an explicit activity call through.- See Also:
-
-
Constructor Details
-
FlutterFragment
public FlutterFragment()
-
-
Method Details
-
createDefault
Creates aFlutterFragment
with a default configuration.FlutterFragment
's default configuration creates a newFlutterEngine
within theFlutterFragment
and uses the following settings:- Dart entrypoint: "main"
- Initial route: "/"
- Render mode: surface
- Transparency mode: transparent
To use a new
FlutterEngine
with different settings, usewithNewEngine()
.To use a cached
FlutterEngine
instead of creating a new one, usewithCachedEngine(String)
. -
withNewEngine
Returns aFlutterFragment.NewEngineFragmentBuilder
to create aFlutterFragment
with a newFlutterEngine
and a desired engine configuration. -
withCachedEngine
@NonNull public static FlutterFragment.CachedEngineFragmentBuilder withCachedEngine(@NonNull String engineId) Returns aFlutterFragment.CachedEngineFragmentBuilder
to create aFlutterFragment
with a cachedFlutterEngine
inFlutterEngineCache
.An
IllegalStateException
will be thrown during the lifecycle of theFlutterFragment
if a cachedFlutterEngine
is requested but does not exist in the cache.To create a
FlutterFragment
that uses a newFlutterEngine
, usecreateDefault()
orwithNewEngine()
. -
withNewEngineInGroup
@NonNull public static FlutterFragment.NewEngineInGroupFragmentBuilder withNewEngineInGroup(@NonNull String engineGroupId) Returns aFlutterFragment.NewEngineInGroupFragmentBuilder
to create aFlutterFragment
with a cachedFlutterEngineGroup
inFlutterEngineGroupCache
.An
IllegalStateException
will be thrown during the lifecycle of theFlutterFragment
if a cachedFlutterEngineGroup
is requested but does not exist in theFlutterEngineGroupCache
. -
createDelegate
public io.flutter.embedding.android.FlutterActivityAndFragmentDelegate createDelegate(io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.Host host) Default delegate factory that creates a simple FlutterActivityAndFragmentDelegate instance.- Specified by:
createDelegate
in interfaceio.flutter.embedding.android.FlutterActivityAndFragmentDelegate.DelegateFactory
-
getExclusiveAppComponent
Returns the Android App Component exclusively attached toFlutterEngine
. -
onAttach
- Overrides:
onAttach
in classandroidx.fragment.app.Fragment
-
onCreate
- Overrides:
onCreate
in classandroidx.fragment.app.Fragment
-
onCreateView
@Nullable public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) - Overrides:
onCreateView
in classandroidx.fragment.app.Fragment
-
onStart
public void onStart()- Overrides:
onStart
in classandroidx.fragment.app.Fragment
-
onResume
public void onResume()- Overrides:
onResume
in classandroidx.fragment.app.Fragment
-
onPostResume
public void onPostResume() -
onPause
public void onPause()- Overrides:
onPause
in classandroidx.fragment.app.Fragment
-
onStop
public void onStop()- Overrides:
onStop
in classandroidx.fragment.app.Fragment
-
onViewCreated
- Overrides:
onViewCreated
in classandroidx.fragment.app.Fragment
-
onDestroyView
public void onDestroyView()- Overrides:
onDestroyView
in classandroidx.fragment.app.Fragment
-
onSaveInstanceState
- Overrides:
onSaveInstanceState
in classandroidx.fragment.app.Fragment
-
detachFromFlutterEngine
public void detachFromFlutterEngine() -
onDetach
public void onDetach()- Overrides:
onDetach
in classandroidx.fragment.app.Fragment
-
onRequestPermissionsResult
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) The result of a permission request has been received.See
Activity.onRequestPermissionsResult(int, String[], int[])
- Overrides:
onRequestPermissionsResult
in classandroidx.fragment.app.Fragment
- Parameters:
requestCode
- identifier passed with the initial permission requestpermissions
- permissions that were requestedgrantResults
- permission grants or denials
-
onNewIntent
A new Intent was received by theActivity
that currently owns thisFragment
.- Parameters:
intent
- new Intent
-
onBackPressed
public void onBackPressed()The hardware back button was pressed.If the fragment uses
shouldAutomaticallyHandleOnBackPressed(true)
, this method should not be called through. It will be called automatically instead. -
onActivityResult
A result has been returned after an invocation ofFragment.startActivityForResult(Intent, int)
.- Overrides:
onActivityResult
in classandroidx.fragment.app.Fragment
- Parameters:
requestCode
- request code sent withFragment.startActivityForResult(Intent, int)
resultCode
- code representing the result of theActivity
that was launcheddata
- any corresponding return data, held within anIntent
-
onUserLeaveHint
public void onUserLeaveHint()TheActivity
that owns thisFragment
is about to go to the background as the result of a user's choice/action, i.e., not as the result of an OS decision. -
onTrimMemory
public void onTrimMemory(int level) Callback invoked when memory is low.This implementation forwards a memory pressure warning to the running Flutter app.
- Specified by:
onTrimMemory
in interfaceComponentCallbacks2
- Parameters:
level
- level
-
getFlutterShellArgs
FlutterActivityAndFragmentDelegate.Host
method that is used byFlutterActivityAndFragmentDelegate
to obtain Flutter shell arguments when initializing Flutter. -
getCachedEngineId
Returns the ID of a statically cachedFlutterEngine
to use within thisFlutterFragment
, ornull
if thisFlutterFragment
does not want to use a cachedFlutterEngine
. -
getCachedEngineGroupId
Returns the ID of a statically cachedFlutterEngineGroup
to use within thisFlutterFragment
, ornull
if thisFlutterFragment
does not want to use a cachedFlutterEngineGroup
. -
shouldDestroyEngineWithHost
public boolean shouldDestroyEngineWithHost()Returns false if theFlutterEngine
within thisFlutterFragment
should outlive theFlutterFragment
, itself.Defaults to true if no custom
is provided
, false if a customFlutterEngine
is provided. -
getDartEntrypointFunctionName
Returns the name of the Dart method that thisFlutterFragment
should execute to start a Flutter app.Defaults to "main".
Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
getDartEntrypointArgs
The Dart entrypoint arguments will be passed as a list of string to Dart's entrypoint function.A value of null means do not pass any arguments to Dart's entrypoint function.
Subclasses may override this method to directly control the Dart entrypoint arguments.
-
getDartEntrypointLibraryUri
Returns the library URI of the Dart method that thisFlutterFragment
should execute to start a Flutter app.Defaults to null (example value: "package:foo/bar.dart").
Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
getAppBundlePath
A custom path to the bundle that contains this Flutter app's resources, e.g., Dart code snapshots.When unspecified, the value is null, which defaults to the app bundle path defined in
FlutterLoader.findAppBundlePath()
.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
getInitialRoute
Returns the initial route that should be rendered within Flutter, once the Flutter app starts.Defaults to
null
, which signifies a route of "/" in Flutter.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
getRenderMode
Returns the desiredRenderMode
for theFlutterView
displayed in thisFlutterFragment
.Defaults to
RenderMode.surface
.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
getTransparencyMode
Returns the desiredTransparencyMode
for theFlutterView
displayed in thisFlutterFragment
.Defaults to
TransparencyMode.transparent
.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
provideFlutterEngine
Hook for subclasses to return aFlutterEngine
with whatever configuration is desired.By default this method defers to this
FlutterFragment
's surroundingActivity
, if thatActivity
implementsFlutterEngineProvider
. If this method is overridden, the surroundingActivity
will no longer be given an opportunity to provide aFlutterEngine
, unless the subclass explicitly implements that behavior.Consider returning a cached
FlutterEngine
instance from this method to avoid the typical warm-up time that a newFlutterEngine
instance requires.If null is returned then a new default
FlutterEngine
will be created to back thisFlutterFragment
.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
- Specified by:
provideFlutterEngine
in interfaceFlutterEngineProvider
- Parameters:
context
- The current context. e.g. An activity.- Returns:
- The Flutter engine.
-
getFlutterEngine
Hook for subclasses to obtain a reference to theFlutterEngine
that is owned by thisFlutterActivity
. -
providePlatformPlugin
@Nullable public PlatformPlugin providePlatformPlugin(@Nullable Activity activity, @NonNull FlutterEngine flutterEngine) -
configureFlutterEngine
Configures aFlutterEngine
after its creation.This method is called after
provideFlutterEngine(Context)
, and after the givenFlutterEngine
has been attached to the owningFragmentActivity
. SeeActivityControlSurface.attachToActivity(ExclusiveAppComponent, Lifecycle)
.It is possible that the owning
FragmentActivity
opted not to connect itself as anActivityControlSurface
. In that case, any configuration, e.g., plugins, must not expect or depend upon an availableActivity
at the time that this method is invoked.The default behavior of this method is to defer to the owning
FragmentActivity
as aFlutterEngineConfigurator
. Subclasses can override this method if the subclass needs to override theFragmentActivity
's behavior, or add to it.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
- Specified by:
configureFlutterEngine
in interfaceFlutterEngineConfigurator
- Parameters:
flutterEngine
- The Flutter engine.
-
cleanUpFlutterEngine
Hook for the host to cleanup references that were established inconfigureFlutterEngine(FlutterEngine)
before the host is destroyed or detached.This method is called in
onDetach()
.- Specified by:
cleanUpFlutterEngine
in interfaceFlutterEngineConfigurator
- Parameters:
flutterEngine
- The Flutter engine.
-
shouldAttachEngineToActivity
public boolean shouldAttachEngineToActivity()SeeshouldAttachEngineToActivity()
andshouldAttachEngineToActivity()
.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate
-
shouldHandleDeeplinking
public boolean shouldHandleDeeplinking()Whether to handle the deeplinking from theIntent
automatically if thegetInitialRoute
returns null. -
onFlutterSurfaceViewCreated
-
onFlutterTextureViewCreated
-
onFlutterUiDisplayed
public void onFlutterUiDisplayed()Invoked after theFlutterView
within thisFlutterFragment
starts rendering pixels to the screen.This method forwards
onFlutterUiDisplayed()
to its attachedActivity
, if the attachedActivity
implementsFlutterUiDisplayListener
.Subclasses that override this method must call through to the
super
method.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
onFlutterUiNoLongerDisplayed
public void onFlutterUiNoLongerDisplayed()Invoked after theFlutterView
within thisFlutterFragment
stops rendering pixels to the screen.This method forwards
onFlutterUiNoLongerDisplayed()
to its attachedActivity
, if the attachedActivity
implementsFlutterUiDisplayListener
.Subclasses that override this method must call through to the
super
method.Used by this
FlutterFragment
'sFlutterActivityAndFragmentDelegate.Host
-
shouldRestoreAndSaveState
public boolean shouldRestoreAndSaveState() -
updateSystemUiOverlays
public void updateSystemUiOverlays() -
shouldDispatchAppLifecycleState
public boolean shouldDispatchAppLifecycleState()Give the host application a chance to take control of the app lifecycle events.Return
false
means the host application dispatches these app lifecycle events, while returntrue
means the engine dispatches these events.Defaults to
true
. -
attachToEngineAutomatically
public boolean attachToEngineAutomatically()Whether to automatically attach theFlutterView
to the engine.Returning
false
means that the task of attaching theFlutterView
to the engine will be taken over by the host application.Defaults to
true
. -
setFrameworkHandlesBack
public void setFrameworkHandlesBack(boolean frameworkHandlesBack) Description copied from interface:PlatformPlugin.PlatformPluginDelegate
The Flutter application would or would not like to handle navigation pop events itself.Relevant for registering and unregistering the app's OnBackInvokedCallback for the Predictive Back feature, for example as in
FlutterActivity
.- Specified by:
setFrameworkHandlesBack
in interfacePlatformPlugin.PlatformPluginDelegate
-
getContext
-
getActivity
-
getLifecycle
@NonNull androidx.lifecycle.Lifecycle getLifecycle()
-