Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. Failed assertion: line ‘!_debugLocked’: I/flutter (24830): is not true in flutter. So today Here I come with all possible solutions for this error.
We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.
How Failed assertion: line ‘!_debugLocked’: I/flutter (24830): is not true Error Occurs ?
I want When popping a screen navigating to other one by clicking on the showBottomSheet, this error is thrown.
I/flutter (24830): The following assertion was thrown building Navigator-[GlobalObjectKey I/flutter (24830): _WidgetsAppState#90d1f](dirty, state: NavigatorState#6b2b6(tickers: tracking 1 ticker)):
I/flutter (24830): 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 1995 pos 12: '!_debugLocked':
I/flutter (24830): is not true.
I/flutter (24830): Either the assertion indicates an error in the framework itself, or we should provide substantially I/flutter (24830): more information in this error message to help you determine and fix the underlying cause.
I/flutter (24830): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (24830): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (24830): When the exception was thrown, this was the stack:
How to Solve Failed assertion: line ‘!_debugLocked’: I/flutter (24830): is not true Error?
- How to Solve Failed assertion: line '!_debugLocked': I/flutter (24830): is not true Error?
To Solve Failed assertion: line '!_debugLocked': I/flutter (24830): is not true Error just add addPostFrameCallback. addPostFrameCallback will avoid this error. So that just wrapping with a
addPostFrameCallback
. The second solution is Setting (Route<dynamic> route) => false will make sure that all routes before the pushed route are removed. This removes all routes in the stack so that users cannot go back to the previous routes after they have logged out. - Failed assertion: line '!_debugLocked': I/flutter (24830): is not true
To Solve Failed assertion: line '!_debugLocked': I/flutter (24830): is not true Error just add addPostFrameCallback. addPostFrameCallback will avoid this error. So that just wrapping with a
addPostFrameCallback
. The second solution is Setting (Route<dynamic> route) => false will make sure that all routes before the pushed route are removed. This removes all routes in the stack so that users cannot go back to the previous routes after they have logged out.
Solution 1: wrapping with a addPostFrameCallback
addPostFrameCallback will avoid this error. So that just wrapping with a addPostFrameCallback
.
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => YourScreen()));
});
Solution 2: (Route<dynamic> route) => false
Setting (Route<dynamic> route) => false
will make sure that all routes before the pushed route are removed. This removes all routes in the stack so that user cannot go back to the previous routes after they have logged out.
Navigator.of(context).pushNamedAndRemoveUntil('/yourscreen', (Route<dynamic> route) => false);
Solution 3: Add Some Delay
Future.delayed(Duration.zero, () {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => YourScreen()),
(route) => false);
});
Summery
So, It’s All About This Error. I hope this tutorial helps you to Solve your error. Please Comment Below if You stucks anywhere with my code. And please comment below which solution worked for you. Thank You.
Also Check Out Below Tutorials
- Flutter: How to fix “A RenderFlex overflowed by pixels ” error?
- No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider
- The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’
- RangeError (index): Invalid value: Valid value range is empty: 0
- Gradle failure A problem occurred evaluating project ‘:app’
Thank you so much, solution number 1 have saved my life..
Thank you, you top man