Skip to content

FlutterNativeView.runFromBundle should support parameters #15798

@mehmetf

Description

@mehmetf

This is important for projects who want to integrate Flutter into their existing apps. There's currently no reasonable way to treat FlutterView like a regular Android view:

  • It does not support different endpoints in Dart. You can specify different endpoints via runFromBundle but if you expose multiple entry points in Dart, the AOT compiler tree-shakes them.
  • There's no easy way of passing parameters to Dart the way you would pass parameters between Android activities via an Intent. The expected way right now is for the Dart app to run and register callbacks that are tied to a PlatformChannel and then the Android shell calls that channel. This works fine for standalone Flutter apps but for a small Flutter activity integrated into a larger Android app, it is a pain.

If we support parameters in runFromBundle, we could do something like this on Dart:

void main([List<String> args]) {
  if (args?.length != 1) return;
  switch (args[1]) {
    case 'page1':
      runApp(new Page1());
      break;
    case 'page2':
      runApp(new Page2());
      break;
  }
}

Ideally the params can be passed further down the app and the app can decide how to route pages but you get the idea.

I assume the same thing will be a problem in iOS as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: existing-appsIntegration with existing apps via the add-to-app flowdependency: dartDart team may need to help usplatform-androidAndroid applications specificallyplatform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions