8000 [go_router] Add default pageBuilder to GoRouter · Issue #113282 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[go_router] Add default pageBuilder to GoRouter #113282
Open
@Skogsfrae

Description

@Skogsfrae

Use case

For custom transitions there's already the possibility to declare a GoRoute with a pageBuilder. In cases where the same custom transition is needed for every page in the app, this method becomes repetitive and redundant.

  GoRouter(
    routes: [
      GoRoute(
        path: '/',
        pageBuilder: (context, state) => MyCustomTransitionPage(
          child: RootPage(),
        ),
        routes: [
          GoRoute(
            path: 'page2',
            pageBuilder: (context, state) => MyCustomTransitionPage(
              child: Page2(),
            ),
          ),
          GoRoute(
            path: 'page3',
            pageBuilder: (context, state) => MyCustomTransitionPage(
              child: Page3(),
            ),
          ),
          GoRoute(
            path: 'page4',
            pageBuilder: (context, state) => MyCustomTransitionPage(
              child: Page4(),
            ),
          ),
        ],
      ),
    ],
  );

Proposal

To solve this issue it would be really great to add a custom pageBuilder to GoRouter constructor and use it (if present) as the default pageBuilder for every GoRoute that only declares a builder

  GoRouter(
    pageBuilder: (context, state, child) => MyCustomTransitionPage(
      child: child,
    ),
    routes: [
      GoRoute(
        path: '/',
        builder: (context, state) => RootPage(),
        routes: [
          GoRoute(
            path: 'page2',
            builder: (context, state) => Page2(),
          ),
          GoRoute(
            path: 'page3',
            builder: (context, state) => Page3(),
          ),
          GoRoute(
            path: 'page4',
            builder: (context, state) => Page4(),
          ),
        ],
      ),
    ],
  );

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0