Field.mask constructor

Field.mask(
  1. String key, {
  2. String? label,
  3. dynamic 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. Widget? prefixIcon,
  13. bool clearable = false,
  14. Widget? clearIcon,
  15. required String? mask,
  16. String match = r'[\w\d]',
  17. bool? maskReturnValue = false,
  18. FieldStyleTextField? style,
  19. dynamic onChanged(
    1. dynamic value
    )?,
})

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

Implementation

Field.mask(
  this.key, {
  this.label,
  dynamic value,
  this.validator,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.hidden = false,
  this.readOnly,
  Widget? prefixIcon,
  bool clearable = false,
  Widget? clearIcon,
  required String? mask,
  String match = r'[\w\d]',
  bool? maskReturnValue = false,
  FieldStyleTextField? style,
  Function(dynamic value)? onChanged,
}) : _value = value,
     this.style = style ?? FieldStyleTextField() {
  setOnChanged(onChanged);

  this.style = (this.style as FieldStyleTextField).copyWith(
    maskedReturnValue: maskReturnValue,
    inputFormatters: [
      MaskTextInputFormatter(
        mask: mask,
        filter: {"#": RegExp(match)},
        type: MaskAutoCompletionType.lazy,
      ),
    ],
  );

  widget = NyFormTextField.fromField(this);
}