静态路由
1. 注册
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| return new MaterialApp( title: 'Flutter 示例', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: 'Flutter 示例主页'), routes: { "SecondPage": (BuildContext context) => new Second() },
);
|
2. 使用
1 2
| Navigator.pushNamed(context, "SecondPage");
|
动态路由
有参跳转
1 2 3 4 5 6 7 8
| Navigator.push(context, new MaterialPageRoute( builder: (BuildContext context) { return new Second(title: "第二个页面"); } ) );
|
无参跳转
1 2 3 4 5 6 7
| Navigator.push( context, new MaterialPageRoute( builder: (context) => new Second() ) );
|
apk,github