From b14353ea517cfb4663729b1859da2c25ef9977bd Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:38:24 -0500 Subject: [PATCH] fix: prevent rendering error on page resize (#2035) --- 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 d3684bd70..b71da7540 100644 --- a/lib/config/routes.dart +++ b/lib/config/routes.dart @@ -160,7 +160,10 @@ abstract class AppRoutes { ), // Pangea# 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) && @@ -640,17 +643,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,