从一个页面跳转到另一个页面
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => // 新页面
);
)
返回到上一层
Navigator.of(context).pop()
返回到根目录
// 1.必须在上跳转之前这样写 (替换)
Navigator.of(context).pushReplacementNamed('/page')
// 2.返回根
Navigator.of(context).pushAndRemoveUntil (
new MaterialPageRoute(builder: (context) => new Tabs(index: 1)),
(route) => route == null
)
本文详细介绍了在Flutter中实现页面跳转和返回的方法,包括如何使用Navigator进行页面切换,以及如何通过push、pop和pushReplacementNamed等方法实现不同场景下的页面导航。
661

被折叠的 条评论
为什么被折叠?



