Field.number constructor

Field.number(
  1. String key, {
  2. String? label,
  3. int? value,
  4. FormValidator? validator,
  5. bool autofocus = false,
  6. String? dummyData,
  7. Widget? header,
  8. Widget? footer,
  9. TextStyle? titleStyle,
  10. bool? hidden = false,
  11. bool? readOnly,
  12. bool decimal = false,
  13. dynamic onChanged(
    1. dynamic value
    )?,
  14. FieldStyleTextField? style,
})

Field.number is a constructor that helps in managing number fields

Implementation

Field.number(
  this.key, {
  this.label,
  int? value,
  this.validator,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.hidden = false,
  this.readOnly,
  bool decimal = false,
  Function(dynamic value)? onChanged,
  FieldStyleTextField? style,
}) : _value = value,
     this.style = style ?? FieldStyleTextField() {
  this.style = (this.style as FieldStyleTextField).copyWith(
    type: "number",
    keyboardType: TextInputType.numberWithOptions(decimal: decimal),
    inputFormatters: decimal
        ? [FilteringTextInputFormatter.allow(RegExp(r'^\d*\.?\d*'))]
        : [FilteringTextInputFormatter.digitsOnly],
  );

  setOnChanged(onChanged);
  widget = NyFormTextField.fromField(this);
}