MinInput constructor

const MinInput({
  1. Key? key,
  2. TextEditingController? controller,
  3. FocusNode? focusNode,
  4. String? placeholder,
  5. Widget? leading,
  6. Widget? trailing,
  7. String? errorText,
  8. bool enabled = true,
  9. bool readOnly = false,
  10. bool autofocus = false,
  11. MinInputType type = MinInputType.text,
  12. MinInputVariant variant = MinInputVariant.normal,
  13. MinInputStyle? style,
  14. TextInputType? keyboardType,
  15. TextInputAction? textInputAction,
  16. TextCapitalization textCapitalization = TextCapitalization.none,
  17. int? maxLines,
  18. int? minLines,
  19. int? maxLength,
  20. bool? obscureText,
  21. ValueChanged<String>? onChanged,
  22. ValueChanged<String>? onSubmitted,
  23. VoidCallback? onEditingComplete,
  24. List<TextInputFormatter>? inputFormatters,
  25. bool? autocorrect,
  26. bool enableSuggestions = true,
  27. double? height,
  28. EdgeInsets contentPadding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
  29. bool showCounter = false,
  30. String? semanticLabel,
})

Implementation

const MinInput({
  super.key,
  this.controller,
  this.focusNode,
  this.placeholder,
  this.leading,
  this.trailing,
  this.errorText,
  this.enabled = true,
  this.readOnly = false,
  this.autofocus = false,
  this.type = MinInputType.text,
  this.variant = MinInputVariant.normal,
  this.style,
  this.keyboardType,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.maxLines,
  this.minLines,
  this.maxLength,
  this.obscureText,
  this.onChanged,
  this.onSubmitted,
  this.onEditingComplete,
  this.inputFormatters,
  this.autocorrect,
  this.enableSuggestions = true,
  this.height,
  this.contentPadding = const EdgeInsets.symmetric(
    horizontal: 12,
    vertical: 8,
  ),
  this.showCounter = false,
  this.semanticLabel,
}) : // La altura fija, si se especifica, debe ser positiva.
     assert(height == null || height > 0, 'height debe ser > 0'),

     // maxLines debe ser positivo si se especifica.
     assert(maxLines == null || maxLines > 0, 'maxLines debe ser > 0'),

     // minLines debe ser positivo si se especifica.
     assert(minLines == null || minLines > 0, 'minLines debe ser > 0'),

     // minLines no puede superar a maxLines cuando ambos se especifican.
     assert(
       minLines == null || maxLines == null || minLines <= maxLines,
       'minLines ($minLines) no puede ser mayor que maxLines ($maxLines)',
     ),

     // maxLength, si se especifica, debe ser al menos 1.
     assert(maxLength == null || maxLength > 0, 'maxLength debe ser > 0'),

     // Un campo multiline no debería tener maxLines = 1 explícitamente,
     // ya que eso contradice la semántica del tipo.
     assert(
       !(type == MinInputType.multiline && maxLines == 1),
       'Un campo de tipo multiline no puede tener maxLines = 1',
     ),

     // Un campo de contraseña no debería ser multiline.
     assert(
       !(type == MinInputType.password && maxLines != null && maxLines > 1),
       'Un campo de tipo password no puede tener maxLines > 1',
     );