createRoute method

  1. @override
Route<T> createRoute(
  1. BuildContext context
)
override

Creates the Route that corresponds to this page.

The created Route must have its Route.settings property set to this Page.

Implementation

@override
Route<T> createRoute(BuildContext context) {
  return switch (routeInfo) {
    DynamicRouteInfo dynamicRouteInfo => () {
        final type = dynamicRouteInfo.when.call(context);

        return switch (type) {
          RouteType.modal => _modalRoute(
              routeInfo: dynamicRouteInfo,
              pageRoute: this,
              transitionDuration:
                  NomoNavigator.of(context).defaultModalTransitionDuration,
              transition: dynamicRouteInfo.transition ??
                  NomoNavigator.of(context).defaultModalTransistion,
              context: context,
            ),
          RouteType.page => _pageRoute(
              routeInfo: dynamicRouteInfo,
              pageRoute: this,
              transitionDuration:
                  NomoNavigator.of(context).defaultTransitionDuration,
              transition: dynamicRouteInfo.transition ??
                  NomoNavigator.of(context).defaultTransistion,
            ),
        };
      }.call(),
    ModalRouteInfo modalRouteInfo => _modalRoute(
        routeInfo: modalRouteInfo,
        pageRoute: this,
        transitionDuration:
            NomoNavigator.of(context).defaultModalTransitionDuration,
        transition: modalRouteInfo.transition ??
            NomoNavigator.of(context).defaultModalTransistion,
        context: context,
      ),
    _ => _pageRoute(
        routeInfo: routeInfo,
        pageRoute: this,
        transitionDuration:
            NomoNavigator.of(context).defaultTransitionDuration,
        transition: routeInfo.transition ??
            NomoNavigator.of(context).defaultTransistion,
      ),
  };
}