-
Notifications
You must be signed in to change notification settings - Fork 176
Routing
Lance Johnstone edited this page Jan 10, 2023
·
1 revision
Flutter platform widgets have a number of widgets and utility functions for combining the Material and Cupertino routing paradigms.
Material
and Cupertino
routing animates differently so in order to use flutter's Navigator
in order to push new routes onto the stack the correct page route needs to be used. This is typically used with the original Navigator
method.
Navigator.push(
context,
platformPageRoute(
context: context,
builder: pageToDisplayBuilder,
),
);
Uses:
Platform | Widget | Extended props add... |
---|---|---|
Material | MaterialPageRoute | material: (_, __) => MaterialPageRouteData(...) |
Cupertino | CupertinoPageRoute | cupertino: (_, __) => CupertinoPageRouteData(...) |
When using the declarative style of navigation routing, specficially when using PlatformApp.router
you can wrap you page level widgets with PlatformPage
so they can be added to the list of pages for the router.
platformPage(
context: context,
child: child,
),
);
Uses:
Platform | Widget | Extended props add... |
---|---|---|
Material | MaterialPage | material: (_, __) => MaterialPageData(...) |
Cupertino | CupertinoPage | cupertino: (_, __) => CupertinoPageData(...) |