IntegerField constructor
IntegerField({
- String? labelPrefix,
- String? label,
- Widget? labelWidget,
- IntegerEditingController? controller,
- FormFieldValidator<
int?> ? validator, - TextAlign textAlign = TextAlign.end,
- int? maxLength,
- FormFieldSetter<
int?> ? onSaved, - int? initialValue,
- bool enabled = true,
- AutovalidateMode autoValidateMode = AutovalidateMode.disabled,
- ValueChanged<
String?> ? onChanged, - FocusNode? focusNode,
- TextInputAction? textInputAction,
- ValueChanged<
String?> ? onFieldSubmitted, - EdgeInsets scrollPadding = const EdgeInsets.all(20),
- bool enableInteractiveSelection = true,
- bool filled = false,
- Color? fillColor,
- Iterable<
String> ? autofillHints, - bool readOnly = false,
- TextStyle? style,
- InputDecoration? decoration,
- EdgeInsets padding = const EdgeInsets.all(8),
- String? hintText,
- EdgeInsets? contentPadding,
- String? counterText = '',
- Widget? prefix,
- Widget? prefixIcon,
- Widget? suffix,
- Widget? suffixIcon,
- void onTap()?,
- int? sizeExtraSmall,
- int? sizeSmall,
- int? sizeMedium,
- int? sizeLarge,
- int? sizeExtraLarge,
- double? minHeight,
- Key? key,
Implementation
IntegerField({
super.labelPrefix,
super.label,
super.labelWidget,
IntegerEditingController? super.controller,
final FormFieldValidator<int?>? validator,
super.textAlign = TextAlign.end,
super.maxLength,
final FormFieldSetter<int?>? onSaved,
final int? initialValue,
super.enabled,
super.autoValidateMode,
super.onChanged,
super.focusNode,
super.textInputAction,
super.onFieldSubmitted,
super.scrollPadding,
super.enableInteractiveSelection,
super.filled,
super.fillColor,
super.autofillHints,
super.readOnly,
super.style,
super.decoration,
super.padding,
super.hintText,
super.contentPadding,
super.counterText,
super.prefix,
super.prefixIcon,
super.suffix,
super.suffixIcon,
super.onTap,
super.sizeExtraSmall,
super.sizeSmall,
super.sizeMedium,
super.sizeLarge,
super.sizeExtraLarge,
super.minHeight,
super.key,
}) : assert(
initialValue == null || controller == null,
'initialValue or controller must be null.',
),
assert(
label == null || labelWidget == null,
'label or labelWidget must be null.',
),
super(
keyboard: TextInputType.number,
validator: (final String? value) {
if (enabled && validator != null) {
return validator(int.tryParse(value ?? ''));
}
return null;
},
minLines: 1,
maxLines: 1,
obscureText: false,
inputFormatter: <TextInputFormatter>[
FilteringTextInputFormatter.allow(RegExp('^-?[0-9]*')),
],
onSaved: (final String? value) {
if (enabled && onSaved != null) {
return onSaved(int.tryParse(value ?? ''));
}
},
initialValue: initialValue?.toString(),
autocorrect: false,
enableSuggestions: false,
textCapitalization: TextCapitalization.none,
);