platformPageRoute<T> function

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

Implementation

PageRoute<T> platformPageRoute<T>({
  required BuildContext context,
  WidgetBuilder? builder,
  RouteSettings? settings,
  bool? maintainState,
  bool? fullscreenDialog,
  String? iosTitle,
  bool allowSnapshotting = true,
  bool barrierDismissible = false,
  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,
      allowSnapshotting: data?.allowSnapshotting ?? allowSnapshotting,
      barrierDismissible: data?.barrierDismissible ?? barrierDismissible,
    );
  } 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,
      allowSnapshotting: data?.allowSnapshotting ?? allowSnapshotting,
      barrierDismissible: data?.barrierDismissible ?? barrierDismissible,
    );
  }
}