Flutter登录页跳转,跳转到其他页面并删除本页

  使用下面的代码进行登录页的跳转,其中 (route) => false,决定了当前页是否删除,从页面导航路由栈中弹出。如果是false则当前页面被删除,弹出导航路由栈,不可返回到当前页;如果是true,则当前页不被删除,仍在导航路由栈,可返回到当前页。
(其中,(route) => route == null, 有错误但不会影响运行,不建议这么写。)

Navigator.pushAndRemoveUntil(
   context,
   MaterialPageRoute(
      builder: (context) => const HomePage(title: "豫安宸景"),
   ),
   (route) => false,
);

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44350337/article/details/122325970
今日推荐