Flutter解决 Failed assertion: line 5142 pos 12: ‘!_debugLocked‘: is not true.

Posted 宾有为

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flutter解决 Failed assertion: line 5142 pos 12: ‘!_debugLocked‘: is not true.相关的知识,希望对你有一定的参考价值。

Flutter入门第四天,在跳转中遇到一个报错,是这样的:Failed assertion: line 4653 pos 12: ‘!_debugLocked’: is not true.
这个报错是真的恶心到我了,看了相关错误,其中这个错误,与我修改并成功正确运行的地方丝毫不相关

直到我看见了这个,事情终于迎来了转机

之所以在这个官方dart文件报错,可能是一下之一:
1、当前布局未加载完成
2、Navigator的跳转动作未完成直接执行新的跳转任务

我解决该问题的方法则是给该跳转方法加上一个延时

Future.delayed(Duration(milliseconds: 500),()
	Navigator.of(buildContext).pushAndRemoveUntil(MaterialPageRoute(builder: (context) => BottomNavigation()), (route) => false);
);

参考:
1、Flutter Failed assertion: line 4830 pos 12: ‘<optimized out>‘: is not true.
2、Flutter Failed assertion: line 4830 pos 12: ‘<optimized out>‘: is not true.

以上是关于Flutter解决 Failed assertion: line 5142 pos 12: ‘!_debugLocked‘: is not true.的主要内容,如果未能解决你的问题,请参考以下文章

Flutter解决 Failed assertion: line 5142 pos 12: ‘!_debugLocked‘: is not true.

Flutter小记6iOS打包Release或ipa后运行异常 Invalid argument(s): Failed to lookup symbol 解决方案

Flutter小记6iOS打包Release或ipa后运行异常 Invalid argument(s): Failed to lookup symbol 解决方案

Flutter小记6iOS打包Release或ipa后运行异常 Invalid argument(s): Failed to lookup symbol 解决方案

FLUTTER:软件包安装错误:SAMSUNG 上的失败 [INSTALL_FAILED_INSUFFICIENT_STORAGE]

Flutter 工程报错 Failed to create provisioning profile.