https://blog.csdn.net/weixin_42869574/article/details/98335757
//第一种
Navigator.push(context, CupertinopageRoute(builder: (context){
return new Page();
}));
//第二种
Navigator.of(context).push(new MaterialPageRoute(builder: (context) {
return new Page();
}));
//第三种
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
routes: {
//Map<String, WidgetBuilder>
"/splash": (context) => new SplashPage(),
"/login": (context) => new LoginPage(),
"/home": (context) => new HomePage(),
"/detail": (context) => new DetailPage(),
},
onUnkNownRoute: (RouteSettings setting) {
String name = setting.name;
print("onUnkNownRoute:$name");
return new MaterialPageRoute(builder: (context) {
return new NotFoundPage();
});
},
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new SplashPage(),
);
}
}
Navigator.of(context).pushNamed("/detail");
//这是返回方法
Navigator.pop(context);
//第一种
Navigator.of(context).pushReplacementNamed("/login");
//第二种
Navigator.pushAndRemoveUntil( context, new MaterialPageRoute(builder: (context) => new Page()),(route) => route == null,);
//第三种
Navigator.of(context).pushNamedAndRemoveUntil("/login", (Route<dynamic> route) => false);
点赞
收藏
————————————————
版权声明:本文为CSDN博主「析木之林」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42869574/java/article/details/98335757
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。