Class FlutterActivity.NewEngineInGroupIntentBuilder

java.lang.Object
io.flutter.embedding.android.FlutterActivity.NewEngineInGroupIntentBuilder
Enclosing class:
FlutterActivity

public static class FlutterActivity.NewEngineInGroupIntentBuilder extends Object
Builder to create an Intent that launches a FlutterActivity with a new FlutterEngine created by FlutterEngineGroup#createAndRunEngine.
  • Constructor Details

    • NewEngineInGroupIntentBuilder

      public NewEngineInGroupIntentBuilder(@NonNull Class<? extends FlutterActivity> activityClass, @NonNull String engineGroupId)
      Constructor that allows this NewEngineInGroupIntentBuilder to be used by subclasses of FlutterActivity.

      Subclasses of FlutterActivity should provide their own static version of FlutterActivity.withNewEngineInGroup(java.lang.String), 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:
      activityClass - A subclass of FlutterActivity.
      engineGroupId - The engine group id.
  • Method Details