A page-based route cannot be completed using imperative api, provide a new list without the corresponding Page to Navigator.pages instead. 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3075 pos 7: '!hasPage || isWaitingForExitingDecision'
Only Navigator.push works. Before Flutter 2 it was working.
Navigator.pushAndRemoveUntil(
context,
PageRouteBuilder(
transitionDuration: const Duration(milliseconds: 3300),
transitionsBuilder: (BuildContext context,
Animation<double> animation,
Animation<double> secondaryAnimation,
Widget child) {
return _CustomPageTransition(
routeAnimation: animation,
fullscreenDialog: false,
child: child);
},
pageBuilder: (_, __, ___) => LoginScreen(),
),
(route) {
print(route.settings.name);
return false;
});
It's an old question that nowaday I solved it by using auto_route package. But I think if you use Navigator.replace it will work.
AutoRouter.of(context).replaceNamed(LoginScreenRoute().path);
Or
AutoRouter.of(context).replace(LoginScreenRoute());
In the MaterialAutoRouter:
@MaterialAutoRouter(routes: <AutoRoute>[
AutoRoute(page: RouteAuthentication, initial: true),
CustomRoute(
page: LoginScreen,
fullscreenDialog: true,
transitionsBuilder: TransitionsBuilders.slideLeftWithFade,durationInMilliseconds: 3300
),])
In my case I wanted to animate with the Hero widget. But the code below doesn't work.
AutoRouter.of(context).pushAndPopUntil(LoginScreenRoute(),
predicate: (_) => false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With