runApp(new MaterialApp(
title: 'ad',
home: new SplashScreen(),
routes: <String, WidgetBuilder>{
'/main': (BuildContext context) => new MainScreen(),
'/login': (BuildContext context) => new LoginScreen()
},
));
- 跳转:pushReplacementNamed跳转之后不能再返回:
Navigator.of(context).pushReplacementNamed('/main');
- 跳转:pushNamed跳转之后可以返回:
Navigator.of(context).pushNamed('/login');
- 跳转并传参数到新页面:
Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context){ return new ThirdPage(title:"请输入昵称"); }))
- 返回上一个页面:
Navigator.pop();
- 返回上一个页面并携带数据参数:
Navigator.pop(context,"携带参数");
- 接收跳转返回携带的数据:
Navigator.pushNamed<String>(context, "nameRoute").then( (String value){
//处理代码
});
Navigator.push<String>(context, new MaterialPageRoute(builder: (BuildContext context){
return new ThirdPage(title:"请输入昵称");
})).then( (String result){
//处理代码
});
网友评论