Add transitioned page router creation function
This commit is contained in:
parent
cbdda22e98
commit
3ebc12f7ff
|
@ -8,7 +8,22 @@ class Router {
|
||||||
AppRoute notFoundRoute;
|
AppRoute notFoundRoute;
|
||||||
|
|
||||||
/// Creates a custom [Route] definition
|
/// Creates a custom [Route] definition
|
||||||
void defineRoute<T extends Route<Null>>(String routePath, {@required RouteCreator creator}) {
|
void defineRoute(String routePath, {@required RouteCreator creator}) {
|
||||||
|
_routeTree.addRoute(new AppRoute(routePath, creator));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Creates a [PageRoute] definition for the passed [RouteHandler]. You can optionally provide a custom
|
||||||
|
/// transition builder for the route.
|
||||||
|
void defineRouteHandler(String routePath, {@required RouteHandler handler, RouteTransitionsBuilder transitionsBuilder,
|
||||||
|
Duration duration = const Duration(milliseconds: 250)})
|
||||||
|
{
|
||||||
|
RouteCreator creator = (RouteSettings routeSettings, Map<String, String> params) {
|
||||||
|
return new PageRouteBuilder(settings: routeSettings, transitionDuration: duration,
|
||||||
|
transitionsBuilder: transitionsBuilder,
|
||||||
|
pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||||
|
return handler(params);
|
||||||
|
});
|
||||||
|
};
|
||||||
_routeTree.addRoute(new AppRoute(routePath, creator));
|
_routeTree.addRoute(new AppRoute(routePath, creator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue