Flutter Engine
The Flutter Engine
|
Classes | |
interface | DelegateFactory |
interface | Host |
Public Member Functions | |
Activity | getAppComponent () |
void | detachFromFlutterEngine () |
Public Member Functions inherited from io.flutter.embedding.android.ExclusiveAppComponent< Activity > | |
void | detachFromFlutterEngine () |
T | getAppComponent () |
Package Functions | |
FlutterActivityAndFragmentDelegate (@NonNull Host host) | |
FlutterActivityAndFragmentDelegate (@NonNull Host host, @Nullable FlutterEngineGroup engineGroup) | |
void | release () |
FlutterEngine | getFlutterEngine () |
boolean | isFlutterEngineFromHost () |
boolean | isAttached () |
void | onAttach (@NonNull Context context) |
void | setUpFlutterEngine () |
View | onCreateView (LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState, int flutterViewId, boolean shouldDelayFirstAndroidViewDraw) |
void | onRestoreInstanceState (@Nullable Bundle bundle) |
void | onStart () |
void | onResume () |
void | onPostResume () |
void | updateSystemUiOverlays () |
void | onPause () |
void | onStop () |
void | onDestroyView () |
void | onSaveInstanceState (@Nullable Bundle bundle) |
void | onDetach () |
void | onBackPressed () |
void | startBackGesture (@NonNull BackEvent backEvent) |
void | updateBackGestureProgress (@NonNull BackEvent backEvent) |
void | commitBackGesture () |
void | cancelBackGesture () |
void | onRequestPermissionsResult (int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) |
void | onNewIntent (@NonNull Intent intent) |
void | onActivityResult (int requestCode, int resultCode, Intent data) |
void | onUserLeaveHint () |
void | onWindowFocusChanged (boolean hasFocus) |
void | onTrimMemory (int level) |
Package Attributes | |
FlutterView | flutterView |
OnPreDrawListener | activePreDrawListener |
Delegate that implements all Flutter logic that is the same between a FlutterActivity
and a FlutterFragment
.
Why does this class exist?
One might ask why an Activity
and Fragment
delegate needs to exist. Given that a Fragment
can be placed within an Activity
, it would make more sense to use a FlutterFragment
within a FlutterActivity
.
The Fragment
support library adds 100k of binary size to an app, and full-Flutter apps do not otherwise require that binary hit. Therefore, it was concluded that Flutter must provide a FlutterActivity
based on the AOSP Activity
, and an independent FlutterFragment
for add-to-app developers.
If a time ever comes where the inclusion of Fragment
s in a full-Flutter app is no longer deemed an issue, this class should be immediately decomposed between FlutterActivity
and FlutterFragment
and then eliminated.
Caution when modifying this class
Any time that a "delegate" is created with the purpose of encapsulating the internal behaviors of another object, that delegate is highly susceptible to degeneration. It is easy to tack new responsibilities on to the delegate which would not otherwise be added to the original object. It is also easy to begin hanging listeners and callbacks on a delegate object that likewise would not be added to the original object. A delegate can quickly become a complex web of dependencies and optional references that are very difficult to track.
Maintainers of this class should take care to only place code in this delegate that would otherwise be placed in either FlutterActivity
or FlutterFragment
, and in exactly the same form. Do not use this class as a convenient shortcut for any other behavior.
Definition at line 75 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Definition at line 117 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Definition at line 121 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from OnBackAnimationCallback#onBackCancelled()
.
This method should be called when a back gesture is cancelled or the back button is pressed. It informs the Flutter framework about the cancellation.
This method enables the Flutter framework to rollback any UI changes or animations initiated in response to the back gesture. This includes resetting UI elements to their state prior to the gesture's start.
Definition at line 879 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from OnBackAnimationCallback#onBackInvoked()
.
This method is called to signify the completion of a back gesture and commits the navigation action initiated by the gesture. It should be invoked as the final step in handling a back gesture.
This method indicates to the Flutter framework that it should proceed with the back navigation, including finalizing animations and updating the UI to reflect the navigation outcome.
Definition at line 857 of file FlutterActivityAndFragmentDelegate.java.
|
inline |
Definition at line 697 of file FlutterActivityAndFragmentDelegate.java.
|
inline |
Definition at line 224 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Returns the io.flutter.embedding.engine.FlutterEngine
that is owned by this delegate and its host Activity
or Fragment
.
Definition at line 150 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Whether or not this FlutterActivityAndFragmentDelegate
is attached to a
.
FlutterEngine
Definition at line 166 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Returns true if the host Activity
/Fragment
provided a FlutterEngine
, as opposed to this delegate creating a new one.
Definition at line 158 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onActivityResult(int, int, Intent)
or
.
Fragment#onActivityResult(int, int, Intent)
This method forwards to interested Flutter plugins.
Definition at line 950 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this method from Activity#onCreate(Bundle)
or
.
Fragment#onAttach(Context)
This method does the following:
io.flutter.embedding.engine.FlutterEngine
. PlatformPlugin
. io.flutter.embedding.engine.FlutterEngine
to the surrounding
Activity
, if desired. io.flutter.embedding.engine.FlutterEngine
via Host#configureFlutterEngine(FlutterEngine)
. Definition at line 188 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from android.app.Activity#onBackPressed()
.
A Fragment
host must have its containing Activity
forward this call so that the Fragment
can then invoke this method.
This method instructs Flutter's navigation system to "pop route".
Definition at line 785 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this method from Activity#onCreate(Bundle)
to create the content View
, or from Fragment#onCreateView(LayoutInflater, ViewGroup, Bundle)
.
inflater
and container
may be null when invoked from an Activity
.
shouldDelayFirstAndroidViewDraw
determines whether to set up an android.view.ViewTreeObserver.OnPreDrawListener
, which will defer the current drawing pass till after the Flutter UI has been displayed. This results in more accurate timings reported with Android tools, such as "Displayed" timing printed with am start
.
Note that it should only be set to true when Host#getRenderMode()
is
.
RenderMode.surface
This method:
FlutterView
in a View
hierarchy FlutterUiDisplayListener
to it io.flutter.embedding.engine.FlutterEngine
to the new FlutterView
View
hierarchy Definition at line 365 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onDestroy()
or Fragment#onDestroyView()
.
This method removes this delegate's FlutterView
's FlutterUiDisplayListener
.
Definition at line 662 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onDestroy()
or Fragment#onDetach()
.
This method:
io.flutter.embedding.engine.FlutterEngine
from its surrounding Activity
, if it was previously attached. PlatformPlugin
. io.flutter.embedding.engine.FlutterEngine
if Host#shouldDestroyEngineWithHost()
()} returns true. Definition at line 729 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onNewIntent(Intent)
.
A Fragment
host must have its containing Activity
forward this call so that the Fragment
can then invoke this method.
This method forwards to interested Flutter plugins.
Definition at line 928 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onPause()
or Fragment#onPause()
.
This method notifies the running Flutter app that it is "inactive" as per the Flutter app lifecycle.
Definition at line 612 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onPostResume()
.
A Fragment
host must have its containing Activity
forward this call so that the Fragment
can then invoke this method.
This method informs the PlatformPlugin
that onPostResume()
has run, which is used to update system UI overlays.
Definition at line 582 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from android.app.Activity#onRequestPermissionsResult(int, String[], int[])
or Fragment#onRequestPermissionsResult(int, String[], int[])
.
This method forwards to interested Flutter plugins.
Definition at line 895 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Definition at line 411 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onResume()
or Fragment#onResume()
.
This method notifies the running Flutter app that it is "resumed" as per the Flutter app lifecycle.
Definition at line 563 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Definition at line 679 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onStart()
or Fragment#onStart()
.
This method:
Definition at line 444 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onStop()
or Fragment#onStop()
.
This method:
io.flutter.embedding.engine.FlutterEngine
from this delegate's FlutterView
. Definition at line 634 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from android.app.Activity#onTrimMemory(int)
.
A Fragment
host must have its containing Activity
forward this call so that the Fragment
can then invoke this method.
This method sends a "memory pressure warning" message to Flutter over the "system channel".
Definition at line 1017 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onUserLeaveHint()
.
A Fragment
host must have its containing Activity
forward this call so that the Fragment
can then invoke this method.
This method forwards to interested Flutter plugins.
Definition at line 978 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from Activity#onWindowFocusChanged()
.
A Fragment
host must have its containing Activity
forward this call so that the Fragment
can then invoke this method.
Definition at line 994 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Disconnects this FlutterActivityAndFragmentDelegate
from its host Activity
or Fragment
.
No further method invocations may occur on this FlutterActivityAndFragmentDelegate
after invoking this method. If a method is invoked, an exception will occur.
This method only clears out references. It does not destroy its io.flutter.embedding.engine.FlutterEngine
. The behavior that destroys a io.flutter.embedding.engine.FlutterEngine
can be found in onDetach()
.
Definition at line 138 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Obtains a reference to a FlutterEngine to back this delegate and its host
.
First, the host
is asked if it would like to use a cached io.flutter.embedding.engine.FlutterEngine
, and if so, the cached io.flutter.embedding.engine.FlutterEngine
is retrieved.
Second, the host
is given an opportunity to provide a io.flutter.embedding.engine.FlutterEngine
via Host#provideFlutterEngine(Context)
.
Third, the host
is asked if it would like to use a cached io.flutter.embedding.engine.FlutterEngineGroup
to create a new FlutterEngine
by FlutterEngineGroup#createAndRunEngine
If the host
does not provide a io.flutter.embedding.engine.FlutterEngine
, then a new FlutterEngine
is instantiated.
Definition at line 276 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from OnBackAnimationCallback#onBackStarted(BackEvent)
.
This method should be called when the back gesture is initiated. It should be invoked as part of the implementation of OnBackAnimationCallback
.
This method delegates the handling of the start of a back gesture to the Flutter framework, which is responsible for the appropriate response, such as initiating animations or preparing the UI for the back navigation process.
backEvent | The BackEvent object containing information about the touch. |
Definition at line 809 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Invoke this from OnBackAnimationCallback#onBackProgressed(BackEvent)
.
This method should be called in response to progress in a back gesture, as part of the implementation of OnBackAnimationCallback
.
This method delegates to the Flutter framework to update UI elements or animations based on the progression of the back gesture.
backEvent | An BackEvent object describing the progress event. |
Definition at line 832 of file FlutterActivityAndFragmentDelegate.java.
|
inlinepackage |
Refreshes Android's window system UI (AKA system chrome) to match Flutter's desired system chrome style.
Definition at line 597 of file FlutterActivityAndFragmentDelegate.java.
|
package |
Definition at line 92 of file FlutterActivityAndFragmentDelegate.java.
|
package |
Definition at line 90 of file FlutterActivityAndFragmentDelegate.java.