MinInput constructor
const
MinInput({
- Key? key,
- TextEditingController? controller,
- FocusNode? focusNode,
- String? placeholder,
- Widget? leading,
- Widget? trailing,
- String? errorText,
- bool enabled = true,
- bool readOnly = false,
- bool autofocus = false,
- MinInputType type = MinInputType.text,
- MinInputVariant variant = MinInputVariant.normal,
- MinInputStyle? style,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- TextCapitalization textCapitalization = TextCapitalization.none,
- int? maxLines,
- int? minLines,
- int? maxLength,
- bool? obscureText,
- ValueChanged<
String> ? onChanged, - ValueChanged<
String> ? onSubmitted, - VoidCallback? onEditingComplete,
- List<
TextInputFormatter> ? inputFormatters, - bool? autocorrect,
- bool enableSuggestions = true,
- double? height,
- EdgeInsets contentPadding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
- bool showCounter = false,
- 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',
);