skip to Main Content

I have a dropdown with an ‘Add’ link that does a Navigator.push to a form for creating a new dropdown element, and that’s all working for the standard case.

However, the dropdown has items related to a connected Bluetooth peripheral, and sometimes that peripheral disconnects, so its dropdown closes, while the form is showing, and, in that case, trying to show an error dialog from that form gives me the error:

I/flutter (20507): ⚠️ Unhandled Dart error: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4532 pos 12: '!_debugLocked': is not true.
I/flutter (20507): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (20507): 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4532 pos 12: '!_debugLocked': is not true.
I/flutter (20507): #0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
I/flutter (20507): #1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
I/flutter (20507): #2      NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4532:12)
I/flutter (20507): #3      NavigatorState.push (package:flutter/src/widgets/navigator.dart:4489:5)
I/flutter (20507): #4      showDialog (package:flutter/src/material/dialog.dart:1297:65)
I/flutter (20507): #5      confirm (package:survey/utilities/widgets/dialog.dart:52:20)
I/flutter (20507): #6      _NtripFormState.handleFailedConnection (package:survey/views/ntrip/form.dart:478:18)
I/flutter (20507): #7      _NtripFormState._testConnection (package:survey/views/ntrip/form.dart:467:20)
I/flutter (20507): <asynchronous suspension>
I/flutter (20507): #8      _NtripFormState.testConnection (package:survey/views/ntrip/form.dart:425:12)
I/flutter (20507): <asynchronous suspension>
I/flutter (20507): #9      _NtripFormState.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:survey/views/ntrip/form.dart:212:54)
I/flutter (20507): <asynchronous suspension>

The '!_debugLocked': is not true. error blocks doing a Navigator.pop while another Navigator.pop is in progress. The _debugLocked variable is private, and because this is an assertion it only throws while running in debug mode, so I can’t check that variable or catch the error in non-debug code.

I also tried wrapping my Navigator.pop calls within Navigator.canPop tests, but that doesn’t seem to handle a pop within a pop.

Is there some way to detect this state, instead of having to keep track of what’s going on in a calling context?

2

Answers


  1. Chosen as BEST ANSWER

    I worked around this issue by Navigator.popping the dropdown before Navigator.pushing the form; the dropdown isn't available to get auto-popped, so the issue is avoided.


  2. I also tried wrapping my Navigator.pop calls within Navigator.canPop
    tests, but that doesn’t seem to handle a pop within a pop.

    do this within a delay

    Future.delayed(const Duration(milliseconds: 500), () {
    
    // here call canPop -> pop
    
    });
    

    Then it will work

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search