flutter - 在描述中描述的这种情况下如何返回登陆屏幕?
问题描述
我是新手,我有一个登录屏幕,在单击登录按钮时,我使用 pushReplacement 推送了一条路线(登陆屏幕)(因为我不想让用户点击返回按钮并再次进入登录屏幕),我的登陆页面由bottomNavigationBar组成,我希望我的bottomNavigtionBar一直在应用程序中持续存在,所以我决定使用persistent_bottom_nav_bar libaray。我的导航栏项目是(主页、搜索和设置),在我的主页navBarItem 子小部件上,我有一个名为“goToNextScreen”的按钮,当我按下“goToNextScreen”按钮时,我按下了一条新路线,现在在下一个屏幕上我只想拥有应用栏上的后退按钮,以便我可以再次回到我的主页 navbarItem 子小部件(登陆屏幕)。
解决方案
要向 AppBar 添加后退按钮,您必须定义前导属性
一个小例子
AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
bottomOpacity: 0,
shadowColor: Colors.transparent,
leading: IconButton(
icon: SvgPicture.asset(
"assets/icons/arrow_back.svg",
color: AppColors.currentAppTheme.boxBackgroundTextColor,
),
onPressed: () {
Navigator.pop(context);
},
),
);
推荐阅读
- scala - 期货列表的 Monix 任务处理失败
- windows - Windows 上的 RUST:获取 LINK:致命错误 LNK1181 错误
- php - 无法访问会话数据 session_write_close
- python - 如何用另一个列表中的数字替换字符串中的数字?
- mysql - 如何修复插入许多重复行的 INSERT INTO ... SELECT 代码?
- spring-boot - spring boot应用程序运行jar文件出错
- html - 引导卡网格的问题
- r - 希望帮助将思想实验转化为 R 代码,使用随机化
- ios - 如何在不使用 Storyboard segue 的情况下将项目从单独的 UIViewController 添加到 UICollectionViewController?
- java - 在 Spring mongo 连接器中反序列化对象数组时获取 MappingException