Field.currency constructor

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

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

Implementation

Field.currency(
  this.key, {
  this.label,
  required String currency,
  String? value,
  this.validator,
  this.autofocus = false,
  this.dummyData,
  this.header,
  this.footer,
  this.titleStyle,
  this.hidden = false,
  this.readOnly,
  Function(dynamic value)? onChanged,
  FieldStyleTextField? style,
}) : _value = value,
     this.style = style ?? FieldStyleTextField() {
  CurrencyMeta currencyMeta = CurrencyInputMatcher.getCurrencyMeta(
    "currency:" + currency,
    value: value ?? "0",
    onChanged: onChanged,
  );

  this.style = (this.style as FieldStyleTextField).copyWith(
    type: "currency",
    keyboardType: const TextInputType.numberWithOptions(decimal: true),
    inputFormatters: [currencyMeta.formatter],
  );

  _value = currencyMeta.initialValue;

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