Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RouteConfig for convenient initialize. #308

Open
dfdgsdfg opened this issue Sep 20, 2022 · 0 comments
Open

Support RouteConfig for convenient initialize. #308

dfdgsdfg opened this issue Sep 20, 2022 · 0 comments

Comments

@dfdgsdfg
Copy link

https://api.flutter.dev/flutter/widgets/RouterConfig-class.html

final routes = RouteMap(
  routes: {
    '/': (_) => CupertinoTabPage(
          child: HomePage(),
          paths: ['/feed', '/settings'],
        ),

    '/feed': (_) => MaterialPage(child: FeedPage()),
    '/settings': (_) => MaterialPage(child: SettingsPage()),
    '/feed/profile/:id': (info) => MaterialPage(
      child: ProfilePage(id: info.pathParameters['id'])
    ),
  }
);

# before
void main() {
  runApp(
      MaterialApp.router(
        routerDelegate: RoutemasterDelegate(routesBuilder: (context) => routes),
        routeInformationParser: RoutemasterParser(),
      ),
  );
}

# after maybe..
void main() {
  runApp(
    MaterialApp.router(
      routerConfig: RouteMaster(routes: routes)
    )
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant