showTextInputDialog function

  1. @useResult
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. bool canPop = true,
  14. PopInvokedCallback? onPopInvoked,
  15. bool autoSubmit = false,
  16. AdaptiveDialogBuilder? builder,
  17. RouteSettings? routeSettings}
)

Implementation

@useResult
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,
  bool canPop = true,
  PopInvokedCallback? onPopInvoked,
  bool autoSubmit = false,
  AdaptiveDialogBuilder? builder,
  RouteSettings? routeSettings,
}) {
  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,
        routeSettings: routeSettings,
        builder: (context) {
          final dialog = IOSTextInputDialog(
            textFields: textFields,
            title: title,
            message: message,
            okLabel: okLabel,
            cancelLabel: cancelLabel,
            isDestructiveAction: isDestructiveAction,
            style: adaptiveStyle,
            useRootNavigator: useRootNavigator,
            canPop: canPop,
            onPopInvoked: onPopInvoked,
            autoSubmit: autoSubmit,
          );
          return builder == null ? dialog : builder(context, dialog);
        },
      );
    case AdaptiveStyle.macOS:
      return showMacosAlertDialog(
        routeSettings: routeSettings,
        useRootNavigator: useRootNavigator,
        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,
              canPop: canPop,
              onPopInvoked: onPopInvoked,
              autoSubmit: autoSubmit,
            ),
          );
          return builder == null ? dialog : builder(context, dialog);
        },
      );
    case AdaptiveStyle.material:
      return showModal(
        context: context,
        useRootNavigator: useRootNavigator,
        routeSettings: routeSettings,
        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,
            canPop: canPop,
            onPopInvoked: onPopInvoked,
            autoSubmit: autoSubmit,
          );
          return builder == null ? dialog : builder(context, dialog);
        },
      );
    case AdaptiveStyle.adaptive:
      assert(false);
      return Future.value();
  }
}