showNikuDialog function

Future<void> showNikuDialog({
  1. required BuildContext context,
  2. required Widget builder(
    1. BuildContext
    ),
  3. String? barrierLabel,
  4. bool useRootNavigator = true,
  5. bool? barrierDismissible,
})

Implementation

Future<void> showNikuDialog({
  required BuildContext context,
  required Widget Function(BuildContext) builder,
  String? barrierLabel,
  bool useRootNavigator = true,
  bool? barrierDismissible,
}) async {
  final alert = builder(context);

  if (alert is NikuAlert) {
    if (alert.adaptive) {
      final platform = Theme.of(context).platform;

      if (platform == TargetPlatform.macOS || platform == TargetPlatform.iOS)
        return showCupertinoDialog(
          context: context,
          builder: builder,
          barrierLabel: barrierLabel,
          barrierDismissible: barrierDismissible ?? false,
          useRootNavigator: useRootNavigator,
        );
    }

    if (alert.cupertino)
      return showCupertinoDialog(
        context: context,
        builder: builder,
        barrierLabel: barrierLabel,
        barrierDismissible: barrierDismissible ?? false,
        useRootNavigator: useRootNavigator,
      );
  }

  return showDialog(
    context: context,
    builder: builder,
    barrierLabel: barrierLabel,
    barrierDismissible: barrierDismissible ?? true,
    useRootNavigator: useRootNavigator,
  );
}