With the normal Navigator, you can provide a custom Route object when you run Navigator.push in order to provide custom animations.
@optionalTypeArgs
static Future<T?> push<T extends Object?>(BuildContext context, Route<T> route) {
return Navigator.of(context).push(route);
}
The reason this is important is because it allows you to specify an exit transition of the underlying page that is being moved away from.
Here is a thread explaining the desired effect.
https://stackoverflow.com/questions/52762069/flutter-transition-exit
With GoRouter, this feature is partially missing.
GoRoute(
path: '/home',
pageBuilder: (context, state) {
return CustomTransitionPage(
key: state.pageKey,
child: const Home(),
opaque: false,
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
return defaultPageTransition(
context,
animation,
child,
reverse: true,
);
},
);
},
),
context.go('/')
There is currently no support go
function that can consume an optional Route to handle exit transitions.
The CustomTransitionPage even provides the secondaryAnimation, mimicing the Navigator's exact behavior. It's simply unused.
I propose an exitTransitionBuilder
in the constructor of CustomTransitionPage or support for a custom Route as an optional parameter in GoRouter.of(context).go('/', ....)
This is a very important missing feature from this package. I am currently unable to create fancier transition animations, and packages Flutter's own animations package https://pub.dev/packages/animations which heavily utilizes exit animations can not replicate their transitions with GoRouter.
Owner Name | flutter |
Repo Name | flutter |
Full Name | flutter/flutter |
Language | Dart |
Created Date | 2015-03-06 |
Updated Date | 2023-03-30 |
Star Count | 151602 |
Watcher Count | 3555 |
Fork Count | 25000 |
Issue Count | 11498 |
Issue Title | Created Date | Updated Date |
---|