IntegerField constructor

IntegerField({
  1. String? labelPrefix,
  2. String? label,
  3. Widget? labelWidget,
  4. IntegerEditingController? controller,
  5. FormFieldValidator<int?>? validator,
  6. TextAlign textAlign = TextAlign.end,
  7. int? maxLength,
  8. FormFieldSetter<int?>? onSaved,
  9. int? initialValue,
  10. bool enabled = true,
  11. AutovalidateMode autoValidateMode = AutovalidateMode.disabled,
  12. ValueChanged<String?>? onChanged,
  13. FocusNode? focusNode,
  14. TextInputAction? textInputAction,
  15. ValueChanged<String?>? onFieldSubmitted,
  16. EdgeInsets scrollPadding = const EdgeInsets.all(20),
  17. bool enableInteractiveSelection = true,
  18. bool filled = false,
  19. Color? fillColor,
  20. Iterable<String>? autofillHints,
  21. bool readOnly = false,
  22. TextStyle? style,
  23. InputDecoration? decoration,
  24. EdgeInsets padding = const EdgeInsets.all(8),
  25. String? hintText,
  26. EdgeInsets? contentPadding,
  27. String? counterText = '',
  28. Widget? prefix,
  29. Widget? prefixIcon,
  30. Widget? suffix,
  31. Widget? suffixIcon,
  32. void onTap()?,
  33. int? sizeExtraSmall,
  34. int? sizeSmall,
  35. int? sizeMedium,
  36. int? sizeLarge,
  37. int? sizeExtraLarge,
  38. double? minHeight,
  39. Key? key,
})

Implementation

IntegerField({
  super.labelPrefix,
  super.label,
  super.labelWidget,
  IntegerEditingController? super.controller,
  FormFieldValidator<int?>? validator,
  super.textAlign = TextAlign.end,
  super.maxLength,
  FormFieldSetter<int?>? onSaved,
  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: (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: (String? value) {
          if (enabled && onSaved != null) {
            return onSaved(int.tryParse(value ?? ''));
          }
        },
        initialValue: initialValue?.toString(),
        autocorrect: false,
        enableSuggestions: false,
        textCapitalization: TextCapitalization.none,
      );