FormDateField<TValue> class
A form to have the date (month and day) selected.
日付(月日)を選択させるためのフォーム。
A form field that allows you to select a date using a modal picker.
Common design can be applied with FormStyle. Also, date values can be managed using FormController.
It has functions such as custom format.
モーダルピッカーにて日付を選択することができるフォームフィールド。
FormStyleで共通したデザインを適用可能。またFormControllerを利用することで日付の値を管理可能。
カスタムフォーマットなどの機能を備えています。
Placement 配置方法
Place under the Form that gave FormController.key, or pass FormController to form.
FormController.keyを与えたForm配下に配置、もしくはformにFormControllerを渡します。
Form Management フォーム管理
When FormController is passed to form, onSaved must also be passed together. The contents of onSaved will be used to save the data.
formにFormControllerを渡した場合、一緒にonSavedも渡してください。データの保存はonSavedの内容が実行されます。
Initial Value and Callbacks 初期値とコールバック
Enter the initial value given by FormController.value in initialValue.
initialValueにFormController.valueから与えられた初期値を入力します。
Each time the content is changed, onChanged is executed.
内容が変更される度onChangedが実行されます。
Validation バリデーション
If FormController.validate is executed, validation and data saving are performed.
FormController.validateが実行された場合、バリデーションとデータの保存を行ないます。
Only when emptyErrorText is specified, emptyErrorText will be displayed as an error if no characters are entered.
emptyErrorTextが指定されている時に限り、文字が入力されていない場合emptyErrorTextがエラーとして表示されます。
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.
それ以外のエラーチェックはvalidatorを指定することで行ないます。 コールバック内でNull以外を返すようにするとその文字列がエラー文として表示されます。Nullの場合はエラーなしとして処理されます。
Event Processing イベント処理
The onSubmitted process is executed when the Enter key or other keys are pressed.
Enterキーなどが押された場合の処理をonSubmittedが実行されます。
Picker Customization ピッカーのカスタマイズ
The date selection method can be set by specifying picker.
pickerを指定することで日付の選択方法を設定することが可能です。
Field State フィールドの状態
If enabled is false, the text is deactivated.
enabledがfalseになるとテキストが非有効化されます。
If readOnly is set to true, the activation is displayed, but the text cannot be changed.
readOnlyがtrueになっている場合は、有効化の表示になりますが、テキストが変更できなくなります。
Basic Usage Example 基本的な使用例
FormDateField(
form: formController,
initialValue: formController.value.date.value,
onSaved: (value) => formController.value.copyWith(date: ModelDate(value)),
);
With Custom Format カスタムフォーマット付きの使用例
FormDateField(
form: formController,
initialValue: formController.value.date.value,
format: "yyyy年MM月dd日",
onSaved: (value) => formController.value.copyWith(date: ModelDate(value)),
);
With Validation バリデーション付きの使用例
FormDateField(
form: formController,
initialValue: formController.value.date.value,
onSaved: (value) => formController.value.copyWith(date: ModelDate(value)),
validator: (value) {
if (value == null) {
return "日付を選択してください";
}
if (value.isBefore(Clock.now())) {
return "過去の日付は選択できません";
}
return null;
},
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FormDateField
Constructors
-
FormDateField({FormController<
TValue> ? form, Key? key, TextEditingController? controller, FormAffixStyle? prefix, FormAffixStyle? suffix, FocusNode? focusNode, TextInputType keyboardType = TextInputType.text, String? hintText, String? labelText, FormStyle? style, bool enabled = true, String? emptyErrorText, bool readOnly = false, FormFieldValidator<DateTime?> ? validator, void onChanged(DateTime? value)?, void onSubmitted(DateTime? value)?, DateTime? initialValue, String? format, FormDateFieldPicker picker = const FormDateFieldPicker(), TValue onSaved(DateTime value)?, bool keepAlive = true, bool showDropdownIcon = true, Widget? dropdownIcon}) -
A form to have the date (month and day) selected.
const
Properties
- controller → TextEditingController?
-
Controller for text forms.
final
- dropdownIcon → Widget?
-
Icon for dropdown. Valid only if showDropdownIcon is
true.final - emptyErrorText → String?
-
Error text. Only displayed if no characters are entered.
final
- enabled → bool
-
If this is
false, it is deactivated.final - focusNode → FocusNode?
-
Specifies the focus node.
final
-
form
→ FormController<
TValue> ? -
Context for forms.
final
- format → String
-
Formatter for formatting DateTime to String.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String?
-
Hint to be displayed on the form. Displayed when no text is entered.
final
- initialValue → DateTime?
-
Initial value.
final
- keepAlive → bool
-
If placed in a list, whether or not it should not be discarded on scrolling.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType
-
Mobile software keyboard type.
final
- labelText → String?
-
Label text for forms.
final
- onChanged → void Function(DateTime? value)?
-
Callback to be executed each time the value is changed.
final
- onSaved → TValue Function(DateTime value)?
-
Callback executed when FormController.validate is executed.
final
- onSubmitted → void Function(DateTime? value)?
-
It is executed when the Enter button on the keyboard or the Submit button on the software keyboard is pressed.
final
- picker → FormDateFieldPicker
-
Picker object for selecting dates.
final
- prefix → FormAffixStyle?
-
A widget that is placed in front of the form.
final
- readOnly → bool
-
If this is
true, the form cannot be filled out and changed from its initial value.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showDropdownIcon → bool
-
true` if you want to display icons for drop-downs.
final
- style → FormStyle?
-
Form Style.
final
- suffix → FormAffixStyle?
-
A widget that is placed after the form.
final
-
validator
→ FormFieldValidator<
DateTime?> ? -
Validator to be executed when FormController.validate is executed.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited