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.
pull/1653/head
Rafał Hirsch 4 days ago
parent 63af3afde4
commit 7b3c1ada03
No known key found for this signature in database

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

Loading…
Cancel
Save