Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.6k stars 405 forks source link

Bad state: Future already completed #1005

Open koral-- opened 2 years ago

koral-- commented 2 years ago

This is an anonymous automated crash report.

StateError: Bad state: Future already completed
  File "future_impl.dart", line 44, in _AsyncCompleter.complete
  File "navigator.dart", line 360, in Route.didComplete
  File "navigator.dart", line 338, in Route.didPop
  File "routes.dart", line 71, in OverlayRoute.didPop
  File "routes.dart", line 262, in TransitionRoute.didPop
  File "routes.dart", line 669, in LocalHistoryRoute.didPop
  File "auto_route_navigator.dart", line 73, in _AutoRouteNavigatorState.build.<fn>
  File "navigator.dart", line 4892, in NavigatorState.pop
  File "navigator.dart", line 4933, in NavigatorState.popUntil
  File "routing_controller.dart", line 921, in StackRouter.popUntil
  File "routing_controller.dart", line 1170, in StackRouter.popUntilRouteWithName

Affected line in my code: AutoRouter.of(context).popUntilRouteWithName(<SomePage>Route.name); It is the loader (modal dialog) hiding, invoked from the cubit listener. However, emissions won't occur if the cubit is closed. I've tried inserting the artificial delays to simulate some race conditions eg. pop the page from which context is taken just before calling popUntilRouteWithName but I could not reproduce any exception so I guess there is a bug in this library.

auto_route: 3.2.4 flutter 2.8.3 Android 12

koral-- commented 4 months ago

A comment for preventing the issue from being automatically closed as the problem is still there.

SamerOrfali22 commented 2 months ago

I'm facing the same issue on the latest version [9.2.2]

ken717w commented 1 month ago

In my case it was popUntilRoot(...) causing this error, replaced it with replaceAll([...]) seems to have resolved it.

Not sure if there would be any side effects, will keep monitor the behaviour.