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.NewEngineFragmentBuilder Class Reference

Public Member Functions

 NewEngineFragmentBuilder ()
 
 NewEngineFragmentBuilder (@NonNull Class<? extends FlutterFragment > subclass)
 
NewEngineFragmentBuilder dartEntrypoint (@NonNull String dartEntrypoint)
 
NewEngineFragmentBuilder dartLibraryUri (@NonNull String dartLibraryUri)
 
NewEngineFragmentBuilder dartEntrypointArgs (@NonNull List< String > dartEntrypointArgs)
 
NewEngineFragmentBuilder initialRoute (@NonNull String initialRoute)
 
NewEngineFragmentBuilder handleDeeplinking (@NonNull Boolean handleDeeplinking)
 
NewEngineFragmentBuilder appBundlePath (@NonNull String appBundlePath)
 
NewEngineFragmentBuilder flutterShellArgs (@NonNull FlutterShellArgs shellArgs)
 
NewEngineFragmentBuilder renderMode (@NonNull RenderMode renderMode)
 
NewEngineFragmentBuilder transparencyMode (@NonNull TransparencyMode transparencyMode)
 
NewEngineFragmentBuilder shouldAttachEngineToActivity (boolean shouldAttachEngineToActivity)
 
NewEngineFragmentBuilder shouldAutomaticallyHandleOnBackPressed (boolean shouldAutomaticallyHandleOnBackPressed)
 
NewEngineFragmentBuilder shouldDelayFirstAndroidViewDraw (boolean shouldDelayFirstAndroidViewDraw)
 

Protected Member Functions

Bundle createArgs ()
 

Package Functions

public< T extends FlutterFragment > T build ()
 

Detailed Description

Builder that creates a new FlutterFragment with arguments that correspond to the values set on this NewEngineFragmentBuilder.

To create a FlutterFragment with default arguments, invoke createDefault().

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

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

  1. Ensure the FlutterFragment subclass has a no-arg constructor.
  2. Subclass this NewEngineFragmentBuilder.
  3. Override the new NewEngineFragmentBuilder'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 NewEngineFragmentBuilder#createArgs(), call through to the super method, then add the new properties as arguments in the Bundle.

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

Definition at line 245 of file FlutterFragment.java.

Constructor & Destructor Documentation

◆ NewEngineFragmentBuilder() [1/2]

io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.NewEngineFragmentBuilder ( )
inline

Constructs a NewEngineFragmentBuilder that is configured to construct an instance of FlutterFragment.

Definition at line 264 of file FlutterFragment.java.

264 {
265 fragmentClass = FlutterFragment.class;
266 }

◆ NewEngineFragmentBuilder() [2/2]

io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.NewEngineFragmentBuilder ( @NonNull Class<? extends FlutterFragment subclass)
inline

Constructs a NewEngineFragmentBuilder that is configured to construct an instance of subclass, which extends FlutterFragment.

Definition at line 272 of file FlutterFragment.java.

272 {
273 fragmentClass = subclass;
274 }

Member Function Documentation

◆ appBundlePath()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.appBundlePath ( @NonNull String  appBundlePath)
inline

The path to the app bundle which contains the Dart app to execute. Null when unspecified, which defaults to io.flutter.embedding.engine.loader.FlutterLoader#findAppBundlePath()

Definition at line 322 of file FlutterFragment.java.

322 {
323 this.appBundlePath = appBundlePath;
324 return this;
325 }

◆ build()

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

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

Definition at line 478 of file FlutterFragment.java.

478 {
479 try {
480 @SuppressWarnings("unchecked")
481 T frag = (T) fragmentClass.getDeclaredConstructor().newInstance();
482 if (frag == null) {
483 throw new RuntimeException(
484 "The FlutterFragment subclass sent in the constructor ("
485 + fragmentClass.getCanonicalName()
486 + ") does not match the expected return type.");
487 }
488
489 Bundle args = createArgs();
490 frag.setArguments(args);
491
492 return frag;
493 } catch (Exception e) {
494 throw new RuntimeException(
495 "Could not instantiate FlutterFragment subclass (" + fragmentClass.getName() + ")", e);
496 }
497 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args

◆ createArgs()

Bundle io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.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 444 of file FlutterFragment.java.

444 {
445 Bundle args = new Bundle();
446 args.putString(ARG_INITIAL_ROUTE, initialRoute);
447 args.putBoolean(ARG_HANDLE_DEEPLINKING, handleDeeplinking);
448 args.putString(ARG_APP_BUNDLE_PATH, appBundlePath);
449 args.putString(ARG_DART_ENTRYPOINT, dartEntrypoint);
450 args.putString(ARG_DART_ENTRYPOINT_URI, dartLibraryUri);
451 args.putStringArrayList(
453 dartEntrypointArgs != null ? new ArrayList(dartEntrypointArgs) : null);
454 // TODO(mattcarroll): determine if we should have an explicit FlutterTestFragment instead of
455 // conflating.
456 if (null != shellArgs) {
457 args.putStringArray(ARG_FLUTTER_INITIALIZATION_ARGS, shellArgs.toArray());
458 }
459 args.putString(
461 renderMode != null ? renderMode.name() : RenderMode.surface.name());
462 args.putString(
464 transparencyMode != null ? transparencyMode.name() : TransparencyMode.transparent.name());
465 args.putBoolean(ARG_SHOULD_ATTACH_ENGINE_TO_ACTIVITY, shouldAttachEngineToActivity);
466 args.putBoolean(ARG_DESTROY_ENGINE_WITH_FRAGMENT, true);
467 args.putBoolean(
468 ARG_SHOULD_AUTOMATICALLY_HANDLE_ON_BACK_PRESSED, shouldAutomaticallyHandleOnBackPressed);
469 args.putBoolean(ARG_SHOULD_DELAY_FIRST_ANDROID_VIEW_DRAW, shouldDelayFirstAndroidViewDraw);
470 return args;
471 }
static final String ARG_SHOULD_AUTOMATICALLY_HANDLE_ON_BACK_PRESSED
VkSurfaceKHR surface
Definition main.cc:49
const char * name
Definition fuchsia.cc:50

◆ dartEntrypoint()

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

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

Definition at line 278 of file FlutterFragment.java.

278 {
279 this.dartEntrypoint = dartEntrypoint;
280 return this;
281 }

◆ dartEntrypointArgs()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.dartEntrypointArgs ( @NonNull List< String >  dartEntrypointArgs)
inline

Arguments passed as a list of string to Dart's entrypoint function.

Definition at line 291 of file FlutterFragment.java.

291 {
292 this.dartEntrypointArgs = dartEntrypointArgs;
293 return this;
294 }

◆ dartLibraryUri()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.dartLibraryUri ( @NonNull String  dartLibraryUri)
inline

Definition at line 284 of file FlutterFragment.java.

284 {
285 this.dartLibraryUri = dartLibraryUri;
286 return this;
287 }

◆ flutterShellArgs()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.flutterShellArgs ( @NonNull FlutterShellArgs  shellArgs)
inline

Any special configuration arguments for the Flutter engine

Definition at line 329 of file FlutterFragment.java.

329 {
330 this.shellArgs = shellArgs;
331 return this;
332 }

◆ handleDeeplinking()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.handleDeeplinking ( @NonNull Boolean  handleDeeplinking)
inline

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

Definition at line 311 of file FlutterFragment.java.

311 {
312 this.handleDeeplinking = handleDeeplinking;
313 return this;
314 }

◆ initialRoute()

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

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

Definition at line 301 of file FlutterFragment.java.

301 {
302 this.initialRoute = initialRoute;
303 return this;
304 }

◆ renderMode()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.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 341 of file FlutterFragment.java.

341 {
342 this.renderMode = renderMode;
343 return this;
344 }

◆ shouldAttachEngineToActivity()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.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 397 of file FlutterFragment.java.

398 {
399 this.shouldAttachEngineToActivity = shouldAttachEngineToActivity;
400 return this;
401 }

◆ shouldAutomaticallyHandleOnBackPressed()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.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 419 of file FlutterFragment.java.

420 {
421 this.shouldAutomaticallyHandleOnBackPressed = shouldAutomaticallyHandleOnBackPressed;
422 return this;
423 }

◆ shouldDelayFirstAndroidViewDraw()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.shouldDelayFirstAndroidViewDraw ( 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 431 of file FlutterFragment.java.

432 {
433 this.shouldDelayFirstAndroidViewDraw = shouldDelayFirstAndroidViewDraw;
434 return this;
435 }

◆ transparencyMode()

NewEngineFragmentBuilder io.flutter.embedding.android.FlutterFragment.NewEngineFragmentBuilder.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 354 of file FlutterFragment.java.

354 {
355 this.transparencyMode = transparencyMode;
356 return this;
357 }

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