textInputDialog static method

Future<void> textInputDialog({
  1. required BuildContext context,
  2. required String title,
  3. required String message,
  4. bool barrierDismissible = true,
  5. String textLeftButton = 'OK',
  6. String textRightButton = 'Cancel',
  7. Function? onPressedLeftButton,
  8. Function? onPressedRightButton,
  9. DestructiveAction destructiveAction = DestructiveAction.right,
  10. DefaultAction defaultAction = DefaultAction.none,
  11. Color androidDestructiveColor = Colors.red,
  12. bool popByDefault = true,
  13. bool hasSecondaryButton = true,
  14. String? placeholder,
  15. TextEditingController? controller,
  16. TextInputType? keyboardType,
  17. Function? onChanged,
  18. Function? onEditingComplete,
})

This method will display a dialog with two buttons that have actions

Implementation

static Future<void> textInputDialog({
  required BuildContext context,
  required String title,
  required String message,
  bool barrierDismissible = true,
  String textLeftButton = 'OK',
  String textRightButton = 'Cancel',
  Function? onPressedLeftButton,
  Function? onPressedRightButton,
  DestructiveAction destructiveAction = DestructiveAction.right,
  DefaultAction defaultAction = DefaultAction.none,
  Color androidDestructiveColor = Colors.red,
  bool popByDefault = true,
  bool hasSecondaryButton = true,
  String? placeholder,
  TextEditingController? controller,
  TextInputType? keyboardType,
  Function? onChanged,
  Function? onEditingComplete,
}) async =>
    await showDialog(
        context: context,
        barrierDismissible: barrierDismissible,
        builder: (context) {
          if (Theme.of(context).platform == TargetPlatform.iOS) {
            return CupertinoTextInputDialog(
              message: message,
              title: title,
              defaultAction: defaultAction,
              destructiveAction: destructiveAction,
              textLeftButton: textLeftButton,
              textRightButton: textRightButton,
              onPressedLeftButton: onPressedLeftButton,
              onPressedRightButton: onPressedRightButton,
              popByDefault: popByDefault,
              hasSecondaryButton: hasSecondaryButton,
              placeholder: placeholder,
              controller: controller,
              keyboardType: keyboardType,
              onChanged: onChanged,
              onEditingComplete: onEditingComplete,
            );
          }

          return MaterialTextInputDialog(
            message: message,
            title: title,
            defaultAction: defaultAction,
            destructiveAction: destructiveAction,
            textLeftButton: textLeftButton,
            textRightButton: textRightButton,
            onPressedLeftButton: onPressedLeftButton,
            onPressedRightButton: onPressedRightButton,
            popByDefault: popByDefault,
            hasSecondaryButton: hasSecondaryButton,
            placeholder: placeholder,
            controller: controller,
            keyboardType: keyboardType,
            onChanged: onChanged,
            onEditingComplete: onEditingComplete,
            androidDestructiveColor: androidDestructiveColor,
          );
        });