InputDecoration constructor Null safety

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