Skip to content

[go_router] builder and pageBuilder's BuildContext should have access to the Navigator and GoRouter instances #110512

@johnpryan

Description

@johnpryan

Currently, the builder doesn't have access to the InheritedGoRouter:

    testWidgets('builder can access GoRouter', (WidgetTester tester) async {
      late final GoRouter buildContextRouter;
      final GoRouter router = GoRouter(
        initialLocation: '/',
        routes: <GoRoute>[
          GoRoute(
            path: '/',
            builder: (BuildContext context, __) {
              buildContextRouter = GoRouter.of(context);
              return const DummyScreen();
            },
          )
        ],
      );

      await tester.pumpWidget(
        MaterialApp.router(
            routeInformationProvider: router.routeInformationProvider,
            routeInformationParser: router.routeInformationParser,
            routerDelegate: router.routerDelegate),
      );

      expect(buildContextRouter, isNotNull);
      expect(buildContextRouter, equals(router));
    });

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions