FormDateTimeRangeField<TValue> constructor
- FormController<
TValue> ? form, - Key? key,
- TextEditingController? controller,
- FormAffixStyle? prefix,
- FormAffixStyle? suffix,
- FormStyle? style,
- TextInputType keyboardType = TextInputType.text,
- String? hintText,
- String? labelText,
- bool enabled = true,
- String? emptyErrorText,
- bool readOnly = false,
- FormFieldValidator<
DateTimeRange?> ? validator, - FocusNode? focusNode,
- void onChanged(
- DateTimeRange? value
- void onSubmitted(
- DateTimeRange? value
- DateTimeRange? initialValue,
- bool keepAlive = true,
- FormDateTimeRangeFieldDelegate delegate = const FormDateTimeRangeFieldDateDelegate(),
- TValue onSaved(
- DateTimeRange value
- bool showDropdownIcon = true,
- 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配下に配置、もしくはform
にFormControllerを渡します。
form
にFormControllerを渡した場合、一緒にonSaved
も渡してください。データの保存はonSaved
の内容が実行されます。
initialValue
にFormController.valueから与えられた初期値を入力します。
内容が変更される度onChanged
が実行されます。
FormController.validateが実行された場合、バリデーションとデータの保存を行ないます。
emptyErrorText
が指定されている時に限り、文字が入力されていない場合emptyErrorText
がエラーとして表示されます。
それ以外のエラーチェックはvalidator
を指定することで行ないます。
コールバック内でNull以外を返すようにするとその文字列がエラー文として表示されます。Nullの場合はエラーなしとして処理されます。
Enterキーなどが押された場合の処理をonSubmitted
が実行されます。
delegate
を指定することで日付範囲の選択方法を設定することが可能です。
enabled
がfalse
になるとテキストが非有効化されます。
readOnly
がtrue
になっている場合は、有効化の表示になりますが、テキストが変更できなくなります。
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].",
);