Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Android活动导航到特定的颤振路线?_Android_Dart_Flutter_Flutter Layout - Fatal编程技术网

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

如何从Android活动导航到特定的颤振路线?,android,dart,flutter,flutter-layout,Android,Dart,Flutter,Flutter Layout,我有一个现有的android应用程序,我在我的项目中集成了颤振,我想调用一个颤振特定的路径,我在我的主要方法中定义了这样的路径 class FlutterView extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Platform View', initialRoute: '/', routes: { '/'

我有一个现有的android应用程序,我在我的项目中集成了颤振,我想调用一个颤振特定的路径,我在我的主要方法中定义了这样的路径

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,
    ),
   );
  }
}
从我的android活动中,我称之为类似于这样的颤振活动

startActivity(新意图(本,activity.class))

它确实打开了我的颤振活动,但使用了initialRoute:“/”,这很好,但有时我想在打开颤振活动时打开eg(“/dashboard”)路线。我如何从Android执行此操作???

,如前所述:

Intent Intent=新的Intent(上下文,MainActivity.class);
intent.setAction(intent.ACTION\u RUN);
意向。额外(“路线”、“路线名称”);
背景。开始触觉(意图);
从颤振,使用:

androidentintent=androidentent(
action:'android.intent.action.RUN',
//将其替换为您的包名。
包:“app.example”,
//将其替换为包名,后跟要打开的活动。
//颤振提供的默认活动是MainActivity,但您可以进行检查
//这将在AndroidManifest.xml中显示。
componentName:'app.example.MainActivity',
//将“routeName”替换为要打开的路由。不要忘记“/”。
参数:{'route':'/routeName'},
);
等待意图。启动();

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

只需创建一个方法频道,并从Android调用flift函数。在该功能中,您可以将应用程序从Flatter导航到任何您想要的位置

有关如何使用方法通道在颤振和本机代码之间进行通信以及如何在本机代码之间进行通信的更多信息,请参见。请看一看


他们有一个从dart发送到本机的示例。不是反向示例。@Alexufo这里是一个很好的教程,他的代码也过时了,但这是在github上寻找新代码示例的方法,谢谢