showYPlatformDialog<T> function

Future<T?> showYPlatformDialog<T>({
  1. required BuildContext context,
  2. required Widget child,
  3. dynamic androidBarrierDismissible = false,
  4. dynamic useRootNavigator = true,
  5. dynamic canPop = false,
  6. Color? androidBarrierColor,
})

Implementation

Future<T?> showYPlatformDialog<T>({
  required BuildContext context,
  required Widget child,
  androidBarrierDismissible = false,
  useRootNavigator = true,
  canPop = false,
  Color? androidBarrierColor,

}) {
  if (kIsWeb) {
    return showDialog<T>(
        context: context,
        builder: (BuildContext context) {
          return PopScope(
              canPop: canPop,
              child: child
          );
        },
        barrierDismissible: androidBarrierDismissible,
        useRootNavigator: useRootNavigator);
  } else {
    final platform = Theme
        .of(context)
        .platform;
    switch (platform) {
      case TargetPlatform.fuchsia:
      case TargetPlatform.linux:
      case TargetPlatform.windows:
      case TargetPlatform.android:
        return showDialog<T>(
          context: context,
          builder: (BuildContext context) {
            return PopScope(
                canPop: canPop,
                child: child
            );
          },
          barrierColor: androidBarrierColor,
          barrierDismissible: androidBarrierDismissible,
          useRootNavigator: useRootNavigator,
        );
      case TargetPlatform.macOS:
      case TargetPlatform.iOS:
        return showCupertinoDialog<T>(
          context: context,
          builder: (BuildContext context) {
            return PopScope(
                canPop: canPop,
                child: child
            );
          },
          useRootNavigator: useRootNavigator,
        );
      default:
        throw UnsupportedError("Platform is not supported by this plugin.");
    }
  }
}