MyTextField constructor

const MyTextField({
  1. Key? key,
  2. TextEditingController? controller,
  3. String? label,
  4. String? hint,
  5. IconData? iconData,
  6. Widget? prefixIcon,
  7. Widget? suffixIcon,
  8. Widget? suffixWidget,
  9. VoidCallback? onClick,
  10. ValueChanged<String>? onSubmitted,
  11. bool border = true,
  12. bool enabled = true,
  13. bool readOnly = false,
  14. bool obscureText = false,
  15. bool autofocus = false,
  16. int? minLines,
  17. int? maxLines = 1,
  18. TextInputType? keyboardType,
  19. TextInputAction? textInputAction,
  20. TextCapitalization textCapitalization = TextCapitalization.sentences,
  21. InputDecoration? inputDecoration,
  22. TextStyle? hintStyle,
})

Creates a customized text field.

Implementation

const MyTextField({
  super.key,
  this.controller,
  this.label,
  this.hint,
  this.iconData,
  this.prefixIcon,
  this.suffixIcon,
  this.suffixWidget,
  this.onClick,
  this.onSubmitted,
  this.border = true, // Default to having an outline border
  this.enabled = true, // Default to enabled
  this.readOnly = false,
  this.obscureText = false,
  this.autofocus = false,
  this.minLines,
  this.maxLines = 1, // Default to single line like TextField
  this.keyboardType,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.sentences, // Sensible default
  this.inputDecoration, // Allow providing a full custom decoration
  this.hintStyle, // Allow overriding hint style
})  : assert(prefixIcon == null || iconData == null,
          'Cannot provide both prefixIcon and iconData'),
      assert(suffixIcon == null || suffixWidget == null,
          'Cannot provide both suffixIcon and suffixWidget');