starter_architecture_flutter_firebase
starter_architecture_flutter_firebase copied to clipboard
Add AppRouteObserver and route name to all pageBuilders
This PR shows how to add a NavigatorObserver to GoRouter-based apps.
Unfortunately, adding observers: [AppRouterObserver()] is not enough and all route names will be null, unless an explicit name is added inside the pageBuilder:
GoRoute(
path: '/jobs',
name: AppRoute.jobs.name,
pageBuilder: (context, state) => NoTransitionPage(
// without this, the NavigatorObserver will report route name == null
name: AppRoute.jobs.name,
child: JobsScreen(),
),
)
But there are still cases where it doesn't work reliably. See this issue for more details: https://github.com/flutter/flutter/issues/112185