如何从Android活动导航到特定的扑扑路线?

sha*_*l.k 5 android dart flutter flutter-layout

我有一个现有的android应用程序,并且在我的项目中集成了flutter,我想调用在我的主要方法中定义的flutter特定路线

class FlutterView extends StatelessWidget {
 @override
  Widget build(BuildContext context) {
  return new MaterialApp(
  title: 'Platform View',
  initialRoute: '/',
  routes: {
    '/': (context) => HomeScreen(),
    '/secound': (context) => MyCustomForm(),
    '/dashboard': (context) => DashBoardScreen(),
    '/login': (context) => LoginScreen(),
  },
  theme: new ThemeData(
    primarySwatch: Colors.red,
    textSelectionColor: Colors.red,
    textSelectionHandleColor: Colors.red,
    ),
   );
  }
}
Run Code Online (Sandbox Code Playgroud)

从我的android活动中,我正在这样叫颤动

startActivity(new Intent(this,FlutterActivity.class));

它的确打开了flutter活动,但是使用了initialRoute:'/'很好,但是有一段时间我想在打开flutter活动时针对eg('/ dashboard')路线打开它,我该怎么做?

Hug*_*sos 9

来自 Android,如下所述

Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Intent.ACTION_RUN);
intent.putExtra("route", "/routeName");
context.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

从 Flutter 中,使用android_intent

AndroidIntent intent = AndroidIntent(
  action: 'android.intent.action.RUN',

  // Replace this by your package name.
  package: 'app.example', 

  // Replace this by your package name followed by the activity you want to open.
  // The default activity provided by Flutter is MainActivity, but you can check
  // this in AndroidManifest.xml.
  componentName: 'app.example.MainActivity', 

  // Replace "routeName" by the route you want to open. Don't forget the "/".
  arguments: {'route': '/routeName'},
);

await intent.launch();
Run Code Online (Sandbox Code Playgroud)

请注意,仅当应用程序终止时,才会在此路由中打开,也就是说,如果应用程序位于前台或后台,则不会在指定的路由中打开。