Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Package Functions | List of all members
io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder Class Reference

Public Member Functions

 NewEngineInGroupFragmentBuilder (@NonNull String engineGroupId)
 
 NewEngineInGroupFragmentBuilder ( @NonNull Class<? extends FlutterFragment > fragmentClass, @NonNull String engineGroupId)
 
NewEngineInGroupFragmentBuilder dartEntrypoint (@NonNull String dartEntrypoint)
 
NewEngineInGroupFragmentBuilder initialRoute (@NonNull String initialRoute)
 
NewEngineInGroupFragmentBuilder handleDeeplinking (@NonNull boolean handleDeeplinking)
 
NewEngineInGroupFragmentBuilder renderMode (@NonNull RenderMode renderMode)
 
NewEngineInGroupFragmentBuilder transparencyMode ( @NonNull TransparencyMode transparencyMode)
 
NewEngineInGroupFragmentBuilder shouldAttachEngineToActivity (boolean shouldAttachEngineToActivity)
 
NewEngineInGroupFragmentBuilder shouldAutomaticallyHandleOnBackPressed (boolean shouldAutomaticallyHandleOnBackPressed)
 
NewEngineInGroupFragmentBuilder shouldDelayFirstAndroidViewDraw ( @NonNull boolean shouldDelayFirstAndroidViewDraw)
 

Protected Member Functions

Bundle createArgs ()
 

Package Functions

public< T extends FlutterFragment > T build ()
 

Detailed Description

Builder that creates a new FlutterFragment that uses a cached io.flutter.embedding.engine.FlutterEngineGroup to create a new io.flutter.embedding.engine.FlutterEngine with arguments that correspond to the values set on this Builder.

Subclasses of FlutterFragment that do not introduce any new arguments can use this Builder to construct instances of the subclass without subclassing this
Builder
. MyFlutterFragment f = new
FlutterFragment.NewEngineInGroupFragmentBuilder(MyFlutterFragment.class, engineGroupId)
.someProperty(...) .someOtherProperty(...) .build<MyFlutterFragment>();

Subclasses of FlutterFragment that introduce new arguments should subclass this NewEngineInGroupFragmentBuilder to add the new properties:

  1. Ensure the FlutterFragment subclass has a no-arg constructor.
  2. Subclass this NewEngineInGroupFragmentBuilder.
  3. Override the new NewEngineInGroupFragmentBuilder's no-arg constructor and invoke the super constructor to set the FlutterFragment subclass: public
    MyBuilder() { super(MyFlutterFragment.class); }
  4. Add appropriate property methods for the new properties.
  5. Override NewEngineInGroupFragmentBuilder#createArgs(), call through to the super method, then add the new properties as arguments in the Bundle.

Once a NewEngineInGroupFragmentBuilder subclass is defined, the FlutterFragment subclass can be instantiated as follows. MyFlutterFragment f = new MyBuilder()
.someExistingProperty(...) .someNewProperty(...) .build<MyFlutterFragment>();

Definition at line 792 of file FlutterFragment.java.

Constructor & Destructor Documentation

◆ NewEngineInGroupFragmentBuilder() [1/2]

io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.NewEngineInGroupFragmentBuilder ( @NonNull String  engineGroupId)
inline

Definition at line 804 of file FlutterFragment.java.

804 {
805 this(FlutterFragment.class, engineGroupId);
806 }

◆ NewEngineInGroupFragmentBuilder() [2/2]

io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.NewEngineInGroupFragmentBuilder ( @NonNull Class<? extends FlutterFragment fragmentClass,
@NonNull String  engineGroupId 
)
inline

Definition at line 808 of file FlutterFragment.java.

809 {
810 this.fragmentClass = fragmentClass;
811 this.cachedEngineGroupId = engineGroupId;
812 }

Member Function Documentation

◆ build()

public< T extends FlutterFragment > T io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.build ( )
inlinepackage

Constructs a new FlutterFragment (or a subclass) that is configured based on properties set on this Builder.

Definition at line 977 of file FlutterFragment.java.

977 {
978 try {
979 @SuppressWarnings("unchecked")
980 T frag = (T) fragmentClass.getDeclaredConstructor().newInstance();
981 if (frag == null) {
982 throw new RuntimeException(
983 "The FlutterFragment subclass sent in the constructor ("
984 + fragmentClass.getCanonicalName()
985 + ") does not match the expected return type.");
986 }
987
988 Bundle args = createArgs();
989 frag.setArguments(args);
990
991 return frag;
992 } catch (Exception e) {
993 throw new RuntimeException(
994 "Could not instantiate FlutterFragment subclass (" + fragmentClass.getName() + ")", e);
995 }
996 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ createArgs()

Bundle io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.createArgs ( )
inlineprotected

Creates a Bundle of arguments that are assigned to the new FlutterFragment.

Subclasses should override this method to add new properties to the Bundle. Subclasses must call through to the super method to collect all existing property values.

Definition at line 952 of file FlutterFragment.java.

952 {
953 Bundle args = new Bundle();
954 args.putString(ARG_CACHED_ENGINE_GROUP_ID, cachedEngineGroupId);
955 args.putString(ARG_DART_ENTRYPOINT, dartEntrypoint);
956 args.putString(ARG_INITIAL_ROUTE, initialRoute);
957 args.putBoolean(ARG_HANDLE_DEEPLINKING, handleDeeplinking);
958 args.putString(
960 renderMode != null ? renderMode.name() : RenderMode.surface.name());
961 args.putString(
963 transparencyMode != null ? transparencyMode.name() : TransparencyMode.transparent.name());
964 args.putBoolean(ARG_SHOULD_ATTACH_ENGINE_TO_ACTIVITY, shouldAttachEngineToActivity);
965 args.putBoolean(ARG_DESTROY_ENGINE_WITH_FRAGMENT, true);
966 args.putBoolean(
967 ARG_SHOULD_AUTOMATICALLY_HANDLE_ON_BACK_PRESSED, shouldAutomaticallyHandleOnBackPressed);
968 args.putBoolean(ARG_SHOULD_DELAY_FIRST_ANDROID_VIEW_DRAW, shouldDelayFirstAndroidViewDraw);
969 return args;
970 }
static final String ARG_SHOULD_AUTOMATICALLY_HANDLE_ON_BACK_PRESSED
VkSurfaceKHR surface
Definition main.cc:49
const char * name
Definition fuchsia.cc:50

◆ dartEntrypoint()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.dartEntrypoint ( @NonNull String  dartEntrypoint)
inline

The name of the initial Dart method to invoke, defaults to "main".

Definition at line 816 of file FlutterFragment.java.

816 {
817 this.dartEntrypoint = dartEntrypoint;
818 return this;
819 }

◆ handleDeeplinking()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.handleDeeplinking ( @NonNull boolean  handleDeeplinking)
inline

Whether to handle the deeplinking from the Intent automatically if the
getInitialRoute
returns null.

Definition at line 836 of file FlutterFragment.java.

836 {
837 this.handleDeeplinking = handleDeeplinking;
838 return this;
839 }

◆ initialRoute()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.initialRoute ( @NonNull String  initialRoute)
inline

The initial route that a Flutter app will render in this FlutterFragment, defaults to "/".

Definition at line 826 of file FlutterFragment.java.

826 {
827 this.initialRoute = initialRoute;
828 return this;
829 }

◆ renderMode()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.renderMode ( @NonNull RenderMode  renderMode)
inline

Render Flutter either as a RenderMode#surface or a RenderMode#texture. You should use surface unless you have a specific reason to use texture.
texture
comes with a significant performance impact, but texture can be displayed beneath other Android Views and animated, whereas surface cannot.

Definition at line 848 of file FlutterFragment.java.

848 {
849 this.renderMode = renderMode;
850 return this;
851 }

◆ shouldAttachEngineToActivity()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.shouldAttachEngineToActivity ( boolean  shouldAttachEngineToActivity)
inline

Whether or not this FlutterFragment should automatically attach its Activity as a control surface for its io.flutter.embedding.engine.FlutterEngine.

Control surfaces are used to provide Android resources and lifecycle events to plugins that are attached to the io.flutter.embedding.engine.FlutterEngine. If
shouldAttachEngineToActivity
is true then this FlutterFragment will connect its io.flutter.embedding.engine.FlutterEngine to the surrounding Activity, along with any plugins that are registered with that FlutterEngine. This allows plugins to access the Activity, as well as receive Activity-specific calls, e.g., android.app.Activity#onNewIntent(Intent). If shouldAttachEngineToActivity is false, then this FlutterFragment will not automatically manage the connection between its io.flutter.embedding.engine.FlutterEngine and the surrounding Activity. The Activity will need to be manually connected to this FlutterFragment's io.flutter.embedding.engine.FlutterEngine by the app developer. See FlutterEngine#getActivityControlSurface().

One reason that a developer might choose to manually manage the relationship between the Activity and io.flutter.embedding.engine.FlutterEngine is if the developer wants to move the FlutterEngine somewhere else. For example, a developer might want the io.flutter.embedding.engine.FlutterEngine to outlive the surrounding
Activity
so that it can be used later in a different Activity. To accomplish this, the io.flutter.embedding.engine.FlutterEngine will need to be disconnected from the surrounding Activity at an unusual time, preventing this FlutterFragment from correctly managing the relationship between the io.flutter.embedding.engine.FlutterEngine and the surrounding Activity.

Another reason that a developer might choose to manually manage the relationship between the Activity and io.flutter.embedding.engine.FlutterEngine is if the developer wants to prevent, or explicitly control when the io.flutter.embedding.engine.FlutterEngine's plugins have access to the surrounding
Activity
. For example, imagine that this FlutterFragment only takes up part of the screen and the app developer wants to ensure that none of the Flutter plugins are able to manipulate the surrounding Activity. In this case, the developer would not want the io.flutter.embedding.engine.FlutterEngine to have access to the Activity, which can be accomplished by setting shouldAttachEngineToActivity to false.

Definition at line 905 of file FlutterFragment.java.

906 {
907 this.shouldAttachEngineToActivity = shouldAttachEngineToActivity;
908 return this;
909 }

◆ shouldAutomaticallyHandleOnBackPressed()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.shouldAutomaticallyHandleOnBackPressed ( boolean  shouldAutomaticallyHandleOnBackPressed)
inline

Whether or not this FlutterFragment should automatically receive onBackPressed() events, rather than requiring an explicit activity call through. Disabled by default.

When enabled, the activity will automatically dispatch back-press events to the fragment's OnBackPressedCallback, instead of requiring the activity to manually call onBackPressed() in client code. If enabled, do not invoke onBackPressed() manually.

This behavior relies on the implementation of popSystemNavigator(). It's not recommended to override that method when enabling this attribute, but if you do, you should always fall back to calling super.popSystemNavigator() when not relying on custom behavior.

Definition at line 927 of file FlutterFragment.java.

928 {
929 this.shouldAutomaticallyHandleOnBackPressed = shouldAutomaticallyHandleOnBackPressed;
930 return this;
931 }

◆ shouldDelayFirstAndroidViewDraw()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.shouldDelayFirstAndroidViewDraw ( @NonNull boolean  shouldDelayFirstAndroidViewDraw)
inline

Whether to delay the Android drawing pass till after the Flutter UI has been displayed.

See {#link FlutterActivityAndFragmentDelegate::onCreateView} for more details.

Definition at line 939 of file FlutterFragment.java.

940 {
941 this.shouldDelayFirstAndroidViewDraw = shouldDelayFirstAndroidViewDraw;
942 return this;
943 }

◆ transparencyMode()

NewEngineInGroupFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineInGroupFragmentBuilder.transparencyMode ( @NonNull TransparencyMode  transparencyMode)
inline

Support a TransparencyMode#transparent background within io.flutter.embedding.android.FlutterView, or force an TransparencyMode#opaque background.

See TransparencyMode for implications of this selection.

Definition at line 861 of file FlutterFragment.java.

862 {
863 this.transparencyMode = transparencyMode;
864 return this;
865 }

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