From 7b3c1ada032937ac8dc37a42889cae1afe1c4373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Hirsch?= Date: Mon, 24 Feb 2025 21:33:09 +0100 Subject: [PATCH] fix: never use a transition on the shell route Changing the PageBuilder here based on a MediaQuery causes the child to briefly be rendered twice with the same GlobalKey, blowing up the rendering. I believe this fixes https://github.com/krille-chan/fluffychat/issues/1534. --- lib/config/routes.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/config/routes.dart b/lib/config/routes.dart index 97e684a6a..c34fd8201 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -87,7 +87,10 @@ abstract class AppRoutes { ), ), ShellRoute( - pageBuilder: (context, state, child) => defaultPageBuilder( + // Never use a transition on the shell route. Changing the PageBuilder + // here based on a MediaQuery causes the child to briefly be rendered + // twice with the same GlobalKey, blowing up the rendering. + pageBuilder: (context, state, child) => noTransitionPageBuilder( context, state, FluffyThemes.isColumnMode(context) && @@ -458,17 +461,24 @@ abstract class AppRoutes { ), ]; + static Page noTransitionPageBuilder( + BuildContext context, + GoRouterState state, + Widget child, + ) => + NoTransitionPage( + key: state.pageKey, + restorationId: state.pageKey.value, + child: child, + ); + static Page defaultPageBuilder( BuildContext context, GoRouterState state, Widget child, ) => FluffyThemes.isColumnMode(context) - ? NoTransitionPage( - key: state.pageKey, - restorationId: state.pageKey.value, - child: child, - ) + ? noTransitionPageBuilder(context, state, child) : MaterialPage( key: state.pageKey, restorationId: state.pageKey.value,