路由
1.通过push实现
FlatButton
onPressed
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context)=>Page_About(title:'About'),
)
);
2. 通过router name实现
MaterialApp下定义routername
MaterialApp
routes: {
'/about':(context)=>Page_About(title:'about')
},
调用处使用
onPressed: (){
Navigator.pushNamed(context, '/about');
},
3. 根路由
MaterialApp中的home替换为initialRoute
MaterialApp
initialRoute: '/',
routes: {
'/':(context)=>RouterDemo(),
}