Bad state: Future already completed
naamapps opened this issue · comments
Hi,
I know there is already an issue with the same error, but I don't think this is the same scenario.
The error occurred when the current visible route is a sub-route of a router, and you're pushing a root route above the sub-route, then quickly dismiss it by tapping the android back button.
It will be easier for you to set the root route as a CupertinoRoute with fullscreenDialog: true, as the animation is slower.
Try going back just before the route animation ends.
I cannot share the full code as the app is private unfortunately, I hope my description of the problem is clear.
Thanks :)
Partial Code:
So the issue is when inside a settings sub-route (pushed via Navigator.of(context) - important to say), and then with a bottom nav bar button push the CreateActionRoute, and quickly pop it via android back button, it will throw the error - but only when the sub-route is the current visible route.
List<AutoRoute> get routes => [
AutoRoute(
page: HomeRoute.page,
initial: true,
children: [
// ..... other routes
// .....
AutoRoute(
page: SettingsRouter.page,
path: 'settings',
children: [
AutoRoute(
page: SettingsRoute.page,
initial: true,
path: '',
),
],
),
],
),
CupertinoRoute(
page: CreateActionRoute.page,
fullscreenDialog: true,
path: '/create-action',
),
];
Full Error:
Bad state: Future already completed
The relevant error-causing widget was:
AutoRouteNavigator
AutoRouteNavigator:file:///Users/naamapps/.pub-cache/hosted/pub.dev/auto_route-8.1.3/lib/src/router/controller/auto_router_delegate.dart:265:16
When the exception was thrown, this was the stack:
#1 Route.didComplete (package:flutter/src/widgets/navigator.dart:423:19)
#2 Route.didPop (package:flutter/src/widgets/navigator.dart:401:5)
#3 OverlayRoute.didPop (package:flutter/src/widgets/routes.dart:78:36)
#4 TransitionRoute.didPop (package:flutter/src/widgets/routes.dart:307:18)
#5 LocalHistoryRoute.didPop (package:flutter/src/widgets/routes.dart:869:18)
#6 _RouteEntry.markForPop (package:flutter/src/widgets/navigator.dart:3314:36)
#7 DefaultTransitionDelegate.resolve.handleExitingRoute (package:flutter/src/widgets/navigator.dart:1102:28)
#8 DefaultTransitionDelegate.resolve (package:flutter/src/widgets/navigator.dart:1141:7)
#9 TransitionDelegate._transition (package:flutter/src/widgets/navigator.dart:918:53)
#10 NavigatorState._updatePages (package:flutter/src/widgets/navigator.dart:4177:43)
#11 NavigatorState.didUpdateWidget (package:flutter/src/widgets/navigator.dart:3837:7)
#12 StatefulElement.update (package:flutter/src/widgets/framework.dart:5659:55)
@naamapps can you check of the latest release fixes your issue?
Latest version did fix the issue! So quick and supportive, you're the best @Milad-Akarie !