I am using Flutter GoRouter to navigate from the Homespace with path / to a search page with path /search. I transition to the search page via context.go('/search').
From the search page when I swipe back, I get a weird animation albeit I am in the correct page.
As per my understanding of your query, you are getting some weird animation at the time of back press from the screen.
Once, I had face same issue and have implemented custom page transition and in that I am passing the page as parameter.
The code of custom transition page will be as mentioned bellow which will help you to remove that default weird looking navigation animation:
route.dart // In my project, I have mentioned all route navigations in separate file.
final _rootNavigatorKey = GlobalKey<NavigatorState>();
final GoRouter goRouterProvider = GoRouter(
navigatorKey: _rootNavigatorKey,
routes: [
GoRoute(
path: AppRoutes.notifications, // Your search route as string will be here...
parentNavigatorKey: _rootNavigatorKey,
pageBuilder: (context, state) => customPageTransition<void>(
context: context,
state: state,
child: const NotificationsScreen(), // Your SearchScreen will be here...
),
),
],
);
Here is the function ‘customPageTransition’ which works expected in my project.
In case, you want to implement any specific transition, you can replace it instead of FadeTransition. you can also define multiple transition as per the requirement as I have did it for the specific use case.
2
Answers
I solved the issue by following this recipe on Github.
As per my understanding of your query, you are getting some weird animation at the time of back press from the screen.
Once, I had face same issue and have implemented custom page transition and in that I am passing the page as parameter.
The code of custom transition page will be as mentioned bellow which will help you to remove that default weird looking navigation animation:
Here is the function ‘customPageTransition’ which works expected in my project.
In case, you want to implement any specific transition, you can replace it instead of FadeTransition. you can also define multiple transition as per the requirement as I have did it for the specific use case.