showTextInputDialog function Null safety

Future<List<String>?> showTextInputDialog(
  1. {required BuildContext context,
  2. required List<DialogTextField> textFields,
  3. String? title,
  4. String? message,
  5. String? okLabel,
  6. String? cancelLabel,
  7. bool isDestructiveAction = false,
  8. bool barrierDismissible = true,
  9. AdaptiveStyle? style,
  10. bool useRootNavigator = true,
  11. VerticalDirection actionsOverflowDirection = VerticalDirection.up,
  12. bool fullyCapitalizedForMaterial = true,
  13. WillPopCallback? onWillPop,
  14. bool autoSubmit = false,
  15. AdaptiveDialogBuilder? builder}
)

Implementation

Future<List<String>?> showTextInputDialog({
  required BuildContext context,
  required List<DialogTextField> textFields,
  String? title,
  String? message,
  String? okLabel,
  String? cancelLabel,
  bool isDestructiveAction = false,
  bool barrierDismissible = true,
  AdaptiveStyle? style,
  bool useRootNavigator = true,
  VerticalDirection actionsOverflowDirection = VerticalDirection.up,
  bool fullyCapitalizedForMaterial = true,
  WillPopCallback? onWillPop,
  bool autoSubmit = false,
  AdaptiveDialogBuilder? builder,
}) {
  final theme = Theme.of(context);
  final adaptiveStyle = style ?? AdaptiveDialog.instance.defaultStyle;
  final effectiveStyle = adaptiveStyle.effectiveStyle(theme);
  switch (effectiveStyle) {
    // ignore: deprecated_member_use_from_same_package
    case AdaptiveStyle.cupertino:
    case AdaptiveStyle.iOS:
      return showCupertinoDialog(
        context: context,
        useRootNavigator: useRootNavigator,
        builder: (context) {
          final dialog = IOSTextInputDialog(
            textFields: textFields,
            title: title,
            message: message,
            okLabel: okLabel,
            cancelLabel: cancelLabel,
            isDestructiveAction: isDestructiveAction,
            style: adaptiveStyle,
            useRootNavigator: useRootNavigator,
            onWillPop: onWillPop,
            autoSubmit: autoSubmit,
          );
          return builder == null ? dialog : builder(context, dialog);
        },
      );
    case AdaptiveStyle.macOS:
      return showMacosAlertDialog(
        context: context,
        builder: (context) {
          final dialog = MacThemeWrapper(
            child: MacOSTextInputDialog(
              textFields: textFields,
              title: title,
              message: message,
              okLabel: okLabel,
              cancelLabel: cancelLabel,
              isDestructiveAction: isDestructiveAction,
              style: adaptiveStyle,
              useRootNavigator: useRootNavigator,
              onWillPop: onWillPop,
              autoSubmit: autoSubmit,
            ),
          );
          return builder == null ? dialog : builder(context, dialog);
        },
      );
    case AdaptiveStyle.material:
      return showModal(
        context: context,
        useRootNavigator: useRootNavigator,
        configuration: FadeScaleTransitionConfiguration(
          barrierDismissible: barrierDismissible,
        ),
        builder: (context) {
          final dialog = MaterialTextInputDialog(
            textFields: textFields,
            title: title,
            message: message,
            okLabel: okLabel,
            cancelLabel: cancelLabel,
            isDestructiveAction: isDestructiveAction,
            style: adaptiveStyle,
            actionsOverflowDirection: actionsOverflowDirection,
            useRootNavigator: useRootNavigator,
            fullyCapitalized: fullyCapitalizedForMaterial,
            onWillPop: onWillPop,
            autoSubmit: autoSubmit,
          );
          return builder == null ? dialog : builder(context, dialog);
        },
      );
    case AdaptiveStyle.adaptive:
      assert(false);
      return Future.value();
  }
}