public static class FlutterFragment.Builder extends Object
FlutterFragment
with arguments
that correspond
to the values set on this Builder
.
To create a FlutterFragment
with default arguments
, invoke build()
without setting any builder properties:
FlutterFragment fragment = new FlutterFragment.Builder().build();
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.Builder(MyFlutterFragment.class)
.someProperty(...)
.someOtherProperty(...)
.build<MyFlutterFragment>();
Subclasses of FlutterFragment
that introduce new arguments should subclass this
Builder
to add the new properties:
FlutterFragment
subclass has a no-arg constructor.Builder
.Builder
's no-arg constructor and invoke the super constructor
to set the FlutterFragment
subclass: public MyBuilder() {
super(MyFlutterFragment.class);
}
createArgs()
, call through to the super method, then add
the new properties as arguments in the Bundle
.Builder
subclass is defined, the FlutterFragment
subclass can be
instantiated as follows.
MyFlutterFragment f = new MyBuilder()
.someExistingProperty(...)
.someNewProperty(...)
.build<MyFlutterFragment>();
Constructor and Description |
---|
Builder()
Constructs a
Builder that is configured to construct an instance of
FlutterFragment . |
Builder(Class<? extends FlutterFragment> subclass)
Constructs a
Builder that is configured to construct an instance of
subclass , which extends FlutterFragment . |
Modifier and Type | Method and Description |
---|---|
FlutterFragment.Builder |
appBundlePath(String appBundlePath)
The path to the app bundle which contains the Dart app to execute, defaults
to
FlutterMain.findAppBundlePath(Context) |
<T extends FlutterFragment> |
build()
Constructs a new
FlutterFragment (or a subclass) that is configured based on
properties set on this Builder . |
protected Bundle |
createArgs()
Creates a
Bundle of arguments that are assigned to the new FlutterFragment . |
FlutterFragment.Builder |
dartEntrypoint(String dartEntrypoint)
The name of the initial Dart method to invoke, defaults to "main".
|
FlutterFragment.Builder |
flutterShellArgs(FlutterShellArgs shellArgs)
Any special configuration arguments for the Flutter engine
|
FlutterFragment.Builder |
initialRoute(String initialRoute)
The initial route that a Flutter app will render in this
FlutterFragment ,
defaults to "/". |
FlutterFragment.Builder |
renderMode(FlutterView.RenderMode renderMode)
Render Flutter either as a
FlutterView.RenderMode.surface or a
FlutterView.RenderMode.texture . |
FlutterFragment.Builder |
transparencyMode(FlutterView.TransparencyMode transparencyMode)
Support a
FlutterView.TransparencyMode.transparent background within FlutterView ,
or force an FlutterView.TransparencyMode.opaque background. |
public Builder()
Builder
that is configured to construct an instance of
FlutterFragment
.public Builder(@NonNull Class<? extends FlutterFragment> subclass)
Builder
that is configured to construct an instance of
subclass
, which extends FlutterFragment
.@NonNull public FlutterFragment.Builder dartEntrypoint(@NonNull String dartEntrypoint)
@NonNull public FlutterFragment.Builder initialRoute(@NonNull String initialRoute)
FlutterFragment
,
defaults to "/".@NonNull public FlutterFragment.Builder appBundlePath(@NonNull String appBundlePath)
FlutterMain.findAppBundlePath(Context)
@NonNull public FlutterFragment.Builder flutterShellArgs(@NonNull FlutterShellArgs shellArgs)
@NonNull public FlutterFragment.Builder renderMode(@NonNull FlutterView.RenderMode renderMode)
FlutterView.RenderMode.surface
or a
FlutterView.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 View
s and animated, whereas surface
cannot.@NonNull public FlutterFragment.Builder transparencyMode(@NonNull FlutterView.TransparencyMode transparencyMode)
FlutterView.TransparencyMode.transparent
background within FlutterView
,
or force an FlutterView.TransparencyMode.opaque
background.
See FlutterView.TransparencyMode
for implications of this selection.
@NonNull public <T extends FlutterFragment> T build()
FlutterFragment
(or a subclass) that is configured based on
properties set on this Builder
.