platformPageRoute<T> function Null safety

PageRoute<T> platformPageRoute<T>(
  1. {required BuildContext context,
  2. WidgetBuilder? builder,
  3. RouteSettings? settings,
  4. bool? maintainState,
  5. bool? fullscreenDialog,
  6. String? iosTitle,
  7. PlatformBuilder<MaterialPageRouteData>? material,
  8. PlatformBuilder<CupertinoPageRouteData>? cupertino}
)

Implementation

PageRoute<T> platformPageRoute<T>({
  required BuildContext context,
  WidgetBuilder? builder,
  RouteSettings? settings,
  bool? maintainState,
  bool? fullscreenDialog,
  String? iosTitle,
  PlatformBuilder<MaterialPageRouteData>? material,
  PlatformBuilder<CupertinoPageRouteData>? cupertino,
}) {
  if (isMaterial(context)) {
    final data = material?.call(context, platform(context));

    return MaterialPageRoute<T>(
      builder: data?.builder ?? builder!,
      settings: data?.settings ?? settings,
      maintainState: data?.maintainState ?? maintainState ?? true,
      fullscreenDialog: data?.fullscreenDialog ?? fullscreenDialog ?? false,
    );
  } else {
    final data = cupertino?.call(context, platform(context));

    return CupertinoPageRoute<T>(
      builder: data?.builder ?? builder!,
      settings: data?.settings ?? settings,
      maintainState: data?.maintainState ?? maintainState ?? true,
      fullscreenDialog: data?.fullscreenDialog ?? fullscreenDialog ?? false,
      title: iosTitle,
    );
  }
}