onCreateRoute method

Route<T> onCreateRoute(
  1. BuildContext context
)

Creates a PageRoute variant based on routeData.type

Implementation

Route<T> onCreateRoute(BuildContext context) {
  final type = routeData.type;
  final title = routeData.title(context);
  if (type is MaterialRouteType) {
    return _PageBasedMaterialPageRoute<T>(page: this);
  } else if (type is CupertinoRouteType) {
    return _PageBasedCupertinoPageRoute<T>(page: this, title: title);
  } else if (type is CustomRouteType) {
    final result = buildPage(context);
    if (type.customRouteBuilder != null) {
      return type.customRouteBuilder!(context, result, this) as Route<T>;
    }
    return _CustomPageBasedPageRouteBuilder<T>(page: this, routeType: type);
  } else if (type is AdaptiveRouteType) {
    if (kIsWeb) {
      return _NoAnimationPageRouteBuilder(page: this);
    } else if ([TargetPlatform.macOS, TargetPlatform.iOS]
        .contains(defaultTargetPlatform)) {
      return _PageBasedCupertinoPageRoute<T>(page: this, title: title);
    }
  }
  return _PageBasedMaterialPageRoute<T>(page: this);
}