.withNewEngine()
.initialRoute(“/my_route”)
.build(currentActivity)
);
2.3 路由启动示例
flutter/lib/main.dart
默认路由
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: ‘Flutter Demo’,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: ‘Flutter Demo Home Page’),
);
}
}
添加路由页面
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: ‘Flutter Demo’,
theme: ThemeData(
primarySwatch: Colors.blue,
),
routes: <String,WidgetBuilder>{
“/”:(context)=>MyHomePage(title: ‘Flutter Demo Home Page’),
‘/a’:(context)=> MyPage(title:‘Page A’),
‘/b’:(context)=> MyPage(title:‘Page B’)
},
//home: MyHomePage(title: ‘Flutter Demo Home Page’),
);
}
}
class MyPage exte