buildAdaptivePageRoute<T> function Null safety

PageRoute<T> buildAdaptivePageRoute<T>(
  1. {required WidgetBuilder builder,
  2. RouteSettings? settings,
  3. bool maintainState = true,
  4. bool fullscreenDialog = false,
  5. String? cupertinoTitle}
)

Implementation

PageRoute<T> buildAdaptivePageRoute<T>({
  required WidgetBuilder builder,
  RouteSettings? settings,
  bool maintainState = true,
  bool fullscreenDialog = false,
  String? cupertinoTitle,
}) {
  assert(builder != null);
  assert(maintainState != null);
  assert(fullscreenDialog != null);
  // no transitions for web
  if (kIsWeb) {
    return PageRouteBuilder(
      pageBuilder: (ctx, _, __) => builder(ctx),
      settings: settings,
      maintainState: maintainState,
      fullscreenDialog: fullscreenDialog,
    );
  } else if (Platform.isIOS || Platform.isMacOS) {
    return CupertinoPageRoute<T>(
      builder: builder,
      settings: settings,
      maintainState: maintainState,
      fullscreenDialog: fullscreenDialog,
      title: cupertinoTitle,
    );
  } else {
    return MaterialPageRoute<T>(
      builder: builder,
      settings: settings,
      maintainState: maintainState,
      fullscreenDialog: fullscreenDialog,
    );
  }
}