InputDecoration constructor Null safety

const InputDecoration(
  1. {Widget? icon,
  2. Widget? label,
  3. String? labelText,
  4. TextStyle? labelStyle,
  5. TextStyle? floatingLabelStyle,
  6. String? helperText,
  7. TextStyle? helperStyle,
  8. int? helperMaxLines,
  9. String? hintText,
  10. TextStyle? hintStyle,
  11. TextDirection? hintTextDirection,
  12. int? hintMaxLines,
  13. String? errorText,
  14. TextStyle? errorStyle,
  15. int? errorMaxLines,
  16. FloatingLabelBehavior? floatingLabelBehavior,
  17. bool isCollapsed,
  18. bool? isDense,
  19. EdgeInsetsGeometry? contentPadding,
  20. Widget? prefixIcon,
  21. BoxConstraints? prefixIconConstraints,
  22. Widget? prefix,
  23. String? prefixText,
  24. TextStyle? prefixStyle,
  25. Widget? suffixIcon,
  26. Widget? suffix,
  27. String? suffixText,
  28. TextStyle? suffixStyle,
  29. BoxConstraints? suffixIconConstraints,
  30. Widget? counter,
  31. String? counterText,
  32. TextStyle? counterStyle,
  33. bool? filled,
  34. Color? fillColor,
  35. Color? focusColor,
  36. Color? hoverColor,
  37. InputBorder? errorBorder,
  38. InputBorder? focusedBorder,
  39. InputBorder? focusedErrorBorder,
  40. InputBorder? disabledBorder,
  41. InputBorder? enabledBorder,
  42. InputBorder? border,
  43. bool enabled,
  44. String? semanticCounterText,
  45. bool? alignLabelWithHint,
  46. BoxConstraints? constraints}
)

Creates a bundle of the border, labels, icons, and styles used to decorate a Material Design text field.

Unless specified by ThemeData.inputDecorationTheme, InputDecorator defaults isDense to false and filled to false. The default border is an instance of UnderlineInputBorder. If border is InputBorder.none then no border is drawn.

The enabled argument must not be null.

Only one of prefix and prefixText can be specified.

Similarly, only one of suffix and suffixText can be specified.

Implementation

const InputDecoration({
  this.icon,
  this.label,
  this.labelText,
  this.labelStyle,
  this.floatingLabelStyle,
  this.helperText,
  this.helperStyle,
  this.helperMaxLines,
  this.hintText,
  this.hintStyle,
  this.hintTextDirection,
  this.hintMaxLines,
  this.errorText,
  this.errorStyle,
  this.errorMaxLines,
  this.floatingLabelBehavior,
  this.isCollapsed = false,
  this.isDense,
  this.contentPadding,
  this.prefixIcon,
  this.prefixIconConstraints,
  this.prefix,
  this.prefixText,
  this.prefixStyle,
  this.suffixIcon,
  this.suffix,
  this.suffixText,
  this.suffixStyle,
  this.suffixIconConstraints,
  this.counter,
  this.counterText,
  this.counterStyle,
  this.filled,
  this.fillColor,
  this.focusColor,
  this.hoverColor,
  this.errorBorder,
  this.focusedBorder,
  this.focusedErrorBorder,
  this.disabledBorder,
  this.enabledBorder,
  this.border,
  this.enabled = true,
  this.semanticCounterText,
  this.alignLabelWithHint,
  this.constraints,
}) : assert(enabled != null),
     assert(!(label != null && labelText != null), 'Declaring both label and labelText is not supported.'),
     assert(!(prefix != null && prefixText != null), 'Declaring both prefix and prefixText is not supported.'),
     assert(!(suffix != null && suffixText != null), 'Declaring both suffix and suffixText is not supported.');