Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder Class Reference

Public Member Functions

 NewEngineInGroupIntentBuilder ( @NonNull Class<? extends FlutterActivity > activityClass, @NonNull String engineGroupId)
 
NewEngineInGroupIntentBuilder dartEntrypoint (@NonNull String dartEntrypoint)
 
NewEngineInGroupIntentBuilder initialRoute (@NonNull String initialRoute)
 
NewEngineInGroupIntentBuilder backgroundMode (@NonNull BackgroundMode backgroundMode)
 
Intent build (@NonNull Context context)
 

Detailed Description

Builder to create an Intent that launches a FlutterActivity with a new FlutterEngine created by FlutterEngineGroup::createAndRunEngine.

Definition at line 482 of file FlutterActivity.java.

Constructor & Destructor Documentation

◆ NewEngineInGroupIntentBuilder()

io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder.NewEngineInGroupIntentBuilder ( @NonNull Class<? extends FlutterActivity activityClass,
@NonNull String  engineGroupId 
)
inline

Constructor that allows this NewEngineInGroupIntentBuilder to be used by subclasses of FlutterActivity.

Subclasses of FlutterActivity should provide their own static version of withNewEngineInGroup, which returns an instance of NewEngineInGroupIntentBuilder constructed with a Class reference to the FlutterActivity subclass, e.g.:

return new NewEngineInGroupIntentBuilder(MyFlutterActivity.class,
cacheedEngineGroupId);


// Create a FlutterEngineGroup, such as in the onCreate method of the Application.
FlutterEngineGroup engineGroup = new FlutterEngineGroup(this);
FlutterEngineGroupCache.getInstance().put("my_cached_engine_group_id", engineGroup);

// Create a NewEngineInGroupIntentBuilder that would build an intent to start my custom FlutterActivity subclass.
FlutterActivity.NewEngineInGroupIntentBuilder intentBuilder =
new FlutterActivity.NewEngineInGroupIntentBuilder(
MyFlutterActivity.class,
app.engineGroupId);
intentBuilder.dartEntrypoint("main")
.initialRoute("/custom/route")
.backgroundMode(BackgroundMode.transparent);
startActivity(intentBuilder.build(context));
Parameters
activityClassA subclass of FlutterActivity.
engineGroupIdThe engine group id.

Definition at line 519 of file FlutterActivity.java.

520 {
521 this.activityClass = activityClass;
522 this.cachedEngineGroupId = engineGroupId;
523 }

Member Function Documentation

◆ backgroundMode()

NewEngineInGroupIntentBuilder io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder.backgroundMode ( @NonNull BackgroundMode  backgroundMode)
inline

The mode of FlutterActivity's background, either BackgroundMode#opaque or BackgroundMode#transparent.

The default background mode is BackgroundMode#opaque.

Choosing a background mode of BackgroundMode#transparent will configure the inner FlutterView of this FlutterActivity to be configured with a FlutterTextureView to support transparency. This choice has a non-trivial performance impact. A transparent background should only be used if it is necessary for the app design being implemented.

A FlutterActivity that is configured with a background mode of BackgroundMode#transparent must have a theme applied to it that includes the following property: <item name="android:windowIsTranslucent">true</item>.

Parameters
backgroundModeThe background mode.
Returns
The engine group intent builder.

Definition at line 571 of file FlutterActivity.java.

571 {
572 this.backgroundMode = backgroundMode.name();
573 return this;
574 }

◆ build()

Intent io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder.build ( @NonNull Context  context)
inline

Creates and returns an Intent that will launch a FlutterActivity with the desired configuration.

Parameters
contextThe context. e.g. An Activity.
Returns
The intent.

Definition at line 584 of file FlutterActivity.java.

584 {
585 return new Intent(context, activityClass)
586 .putExtra(EXTRA_DART_ENTRYPOINT, dartEntrypoint)
587 .putExtra(EXTRA_INITIAL_ROUTE, initialRoute)
588 .putExtra(EXTRA_CACHED_ENGINE_GROUP_ID, cachedEngineGroupId)
589 .putExtra(EXTRA_BACKGROUND_MODE, backgroundMode)
590 .putExtra(EXTRA_DESTROY_ENGINE_WITH_ACTIVITY, true);
591 }

◆ dartEntrypoint()

NewEngineInGroupIntentBuilder io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder.dartEntrypoint ( @NonNull String  dartEntrypoint)
inline

The Dart entrypoint that will be executed in the newly created FlutterEngine as soon as the Dart snapshot is loaded. Default to "main".

Parameters
dartEntrypointThe dart entrypoint's name
Returns
The engine group intent builder

Definition at line 533 of file FlutterActivity.java.

533 {
534 this.dartEntrypoint = dartEntrypoint;
535 return this;
536 }

◆ initialRoute()

NewEngineInGroupIntentBuilder io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder.initialRoute ( @NonNull String  initialRoute)
inline

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

Parameters
initialRouteThe route.
Returns
The engine group intent builder.

Definition at line 546 of file FlutterActivity.java.

546 {
547 this.initialRoute = initialRoute;
548 return this;
549 }

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