Looking up a deactivated widget‘s ancestor is unsafe

2023-11-21 07:44

本文主要是介绍Looking up a deactivated widget‘s ancestor is unsafe,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

背景:
showCupertinoModalPopup
中使用Navigator.of(context).pushNamedAndRemoveUntil(RouteName.login, (route) => false);
报错:Looking up a deactivated widget’s ancestor is unsafe

解决方案:先将CupertinoModal关闭,再使用不同的的context去跳转;
注意: _context和context是不同的

Navigator.pop(_context); Future.delayed(Duration(milliseconds: 300), () { Navigator.of(context) .pushNamedAndRemoveUntil(RouteName.login, (Route<dynamic> route) => false); });

void _showAlertDialog(BuildContext context) {showCupertinoModalPopup<void>(context: context,builder: (BuildContext _context) => CupertinoAlertDialog(title: const Text('退出后不删除任何历史数据, 请确认是否退出'),// content: const Text('Proceed with destructive action?'),actions: <CupertinoDialogAction>[CupertinoDialogAction(/// This parameter indicates this action is the default,/// and turns the action's text to bold text.isDefaultAction: true,onPressed: () {Navigator.pop(_context);},child: const Text('取消'),),CupertinoDialogAction(/// This parameter indicates the action would perform/// a destructive action such as deletion, and turns/// the action's text color to red.isDestructiveAction: true,onPressed: () async {// final isLogout = await loginOut();// await UserUtil.cleanToKen();Navigator.pop(_context);Future.delayed(Duration(milliseconds: 300), () {Navigator.of(context).pushNamedAndRemoveUntil(RouteName.login, (Route<dynamic> route) => false);});},child: const Text('退出登录'),),],),);}

这篇关于Looking up a deactivated widget‘s ancestor is unsafe的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/400872

相关文章

如何在Qt的widget上右键显示菜单

如何在Qt的widget上右键显示菜单 今天早上一来,我老大叫我在widget上点击右键加上一个菜单,并相应其响应的功能,因为我成刚接触Qt,所以看了下QtGUI编程这本书,做出来,记录下来,说不定哪天还用得上啊! 废话不多说,直接上代码: 方法一: m_text = QTextCodec::codecForLocale(); ui->tableWidget->addAction(ne

QT窗体Widget使用的若干问题

这里介绍的是widget 窗体的属性 最完整的属性请查看qt自带的帮助文档,这里之拿了一部分做说明 窗体属性: object name:物件名称 qwidget:enable 使能本部件 geometry:窗口位置和大小设置 sizepolicy: 1. Fixed: 大小不能改变 2. Minimum: 已经是最小, 不能再被缩小, 但

cannot be cast toandroid.widget.HeaderViewListAdapter

在做上拉刷新的时候,想要在下拉到底部的时候通过addFooterView给listview添加一个view,遇到这个异常 网上找到解决方法之后,记录下。 ---------------------------------------------- cannot be cast toandroid.widget.HeaderViewListAdapter 用listview设置h

error C4996: 'fopen': This function or variable may be unsafe.

今天在vs2013编程中遇到这样的错误:error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use_CRT_SECURE_NO_WARNINGS. See online help for details

Binary Tree - Lowest Common Ancestor 题型总结

Lowest Common Ancestor of a Binary Search Tree 思路:这题跟 Lowest Common Ancestor of Binary Tree 一模一样。思路:就是找p的节点在不在左支,或者右支,找到各自左右节点,然后进行比较,如果两者不一样,说明当前的root就是lowest 父节点,如果左边为空,那就都在右边,返回右边的即可,如果右边为空,那就都在左

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams 报错原因: ImageView image =(ImageView) findViewById(R.id.imageView1)

unsafe 库使用小结

unsafe 库让 golang 可以像 C 语言一样操作计算机内存,但这并不是 golang 推荐使用的,能不用尽量不用,就像它的名字所表达的一样,它绕过了golang的内存安全原则,是不安全的,容易使你的程序出现莫名其妙的问题,不利于程序的扩展与维护。 unsafe 包的内容不多,下面就它提供的函数进行说明 unsafe.Alignof 获取变量的对齐值,除 int、uintptr 这些

error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To d

编译出错信息:错误    1    error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.   首

JBOSS启动报错Given parent is not an ancestor of this virt

环境:JBOSS AS 7、 Linux、JDK1.7 报错信息: 2017-07-13 10:07:16,764 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.unit."voc.war".STRUCTURE: org

VS编写c程序时提示This function or variable may be unsafe

最近小编在准备考研,在使用vs编写c语言的代码时报错This function or variable may be unsafe,看了自己的代码,确定没有问题,然后就想应该是软件的问题。废话不说了,直接说解决方法。 1.打开出错的代码文件 2.在工程文件名处右击鼠标打开属性选项。 3.在属性页面中找到“C/C++"——”预处理器“点击向下的尖角,点击编