FormDateTimeRangeField<TValue> constructor

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

Form to have a range of dates selected.

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.

You can set how to select a date range by specifying delegate.

If enabled is false, the text is deactivated.

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

日付の範囲を選択させるためのフォーム。

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

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

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

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

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

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

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

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

delegateを指定することで日付範囲の選択方法を設定することが可能です。

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

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

Implementation

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