FormEnumField<TEnum extends Enum, TValue> constructor

const FormEnumField<TEnum extends Enum, TValue>({
  1. FormController<TValue>? form,
  2. Key? key,
  3. TextEditingController? controller,
  4. FormAffixStyle? prefix,
  5. FormAffixStyle? suffix,
  6. String? hintText,
  7. String? labelText,
  8. String? emptyErrorText,
  9. FormStyle? style,
  10. bool enabled = true,
  11. bool readOnly = false,
  12. FormFieldValidator<TEnum?>? validator,
  13. void onChanged(
    1. TEnum? value
    )?,
  14. void onSubmitted(
    1. TEnum? value
    )?,
  15. TEnum? initialValue,
  16. required FormEnumFieldPicker<TEnum> picker,
  17. TValue onSaved(
    1. TEnum value
    )?,
  18. FocusNode? focusNode,
  19. bool keepAlive = true,
  20. bool showDropdownIcon = true,
  21. Widget? dropdownIcon,
})

Form to select from all elements in TEnum.

Place under the Form that gave FormController.key, or pass FormController to form.

When FormController is passed to form, onSaved must also be passed together. The contents of onSaved will be used to save the data.

Enter the initial value given by FormController.value in initialValue.

Each time the content is changed, onChanged is executed.

If FormController.validate is executed, validation and data saving are performed.

Only when emptyErrorText is specified, emptyErrorText will be displayed as an error if no characters are entered.

Other error checking is performed by specifying validator. If a string other than Null is returned in the callback, the string is displayed as an error statement. If Null is returned, it is processed as no error.

The onSubmitted process is executed when the Enter key or other keys are pressed.

By specifying picker, it is possible to set the selection method for TEnum.

If enabled is false, the text is deactivated.

If readOnly is set to true, the activation is displayed, but the text cannot be changed.

TEnumのすべての要素から選択するためのフォーム。

FormController.keyを与えたForm配下に配置、もしくはformFormControllerを渡します。

formFormControllerを渡した場合、一緒にonSavedも渡してください。データの保存はonSavedの内容が実行されます。

initialValueFormController.valueから与えられた初期値を入力します。

内容が変更される度onChangedが実行されます。

FormController.validateが実行された場合、バリデーションとデータの保存を行ないます。

emptyErrorTextが指定されている時に限り、文字が入力されていない場合emptyErrorTextがエラーとして表示されます。

それ以外のエラーチェックはvalidatorを指定することで行ないます。 コールバック内でNull以外を返すようにするとその文字列がエラー文として表示されます。Nullの場合はエラーなしとして処理されます。

Enterキーなどが押された場合の処理をonSubmittedが実行されます。

pickerを指定することでTEnumの選択方法を設定することが可能です。

enabledfalseになるとテキストが非有効化されます。

readOnlytrueになっている場合は、有効化の表示になりますが、テキストが変更できなくなります。

Implementation

const FormEnumField({
  this.form,
  super.key,
  this.controller,
  this.prefix,
  this.suffix,
  this.hintText,
  this.labelText,
  this.emptyErrorText,
  this.style,
  this.enabled = true,
  this.readOnly = false,
  this.validator,
  this.onChanged,
  this.onSubmitted,
  this.initialValue,
  required this.picker,
  this.onSaved,
  this.focusNode,
  this.keepAlive = true,
  this.showDropdownIcon = true,
  this.dropdownIcon,
}) : assert(
        (form == null && onSaved == null) ||
            (form != null && onSaved != null),
        "Both are required when using [form] or [onSaved].",
      );