fix: prevent rendering error on page resize (#2035)

This commit is contained in:
ggurdin 2025-03-04 11:38:24 -05:00 committed by GitHub
parent 12951c3c48
commit b14353ea51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,