FDateField class abstract
A date field allows a date to be selected from a calendar, input field, or both.
A FDateField is internally a FormField, therefore it can be used in a Form.
It is recommended to use FDateField.calendar on touch devices and FDateField.new/FDateField.input on non-touch devices.
The input field supports both arrow key navigation:
- Up/Down arrows: Increment/decrement values
- Left/Right arrows: Move between date segments
The input field does not support the following locales that use non-western numerals, it will default to English:
- Arabic (العربية)
- Assamese (অসমীয়া)
- Bengali (বাংলা)
- Persian/Farsi (فارسی)
- Marathi (मराठी)
- Burmese (မြန်မာ)
- Nepali (नेपाली)
- Pashto (پښتو)
- Tamil (தமிழ்)
Consider providing a FDateFieldController.validator to perform custom date validation logic. By default, all dates are valid.
See:
- https://forui.dev/docs/form/date-field for working examples.
- FDateFieldController for controlling a date field.
- FDateFieldCalendarProperties for customizing a date field calendar's behavior.
- FDateFieldStyle for customizing a date field's appearance.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FDateField
Constructors
-
FDateField({FDateFieldControl control, FPopoverControl popoverControl, FTextFieldSizeVariant size, FDateFieldStyleDelta style, FocusNode? focusNode, TextInputAction? textInputAction, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool autofocus, bool expands, VoidCallback? onEditingComplete, ValueChanged<
DateTime> ? onSubmit, MouseCursor? mouseCursor, bool canRequestFocus, bool clearable, FDateFieldPopoverBuilder popoverBuilder, int baselineInputYear, FFieldBuilder<FDateFieldStyle> builder, FFieldIconBuilder<FTextFieldStyle> ? prefixBuilder, FFieldIconBuilder<FTextFieldStyle> ? suffixBuilder, FDateFieldCalendarProperties calendar, Widget? label, Widget? description, bool enabled, FormFieldSetter<DateTime> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext context, String message), Key? formFieldKey, Key? key}) -
Creates a FDateField that allows date selection through both an input field and a calendar popover.
constfactory
-
FDateField.calendar({FDateFieldControl control, FPopoverControl popoverControl, FTextFieldSizeVariant size, FDateFieldStyleDelta style, DateFormat? format, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, String? hint, bool autofocus, FocusNode? focusNode, Alignment anchor, Alignment fieldAnchor, FPortalSpacing spacing, FPortalOverflow overflow, Offset offset, bool useViewPadding, bool useViewInsets, FPopoverHideRegion hideRegion, Object? groupId, VoidCallback? onTapHide, bool cutout, void cutoutBuilder(Path path, Rect bounds), FDateFieldPopoverBuilder popoverBuilder, ValueWidgetBuilder<
FCalendarDayData> dayBuilder, DateTime? start, DateTime? end, DateTime? today, FCalendarPickerType initialType, bool autoHide, FFieldBuilder<FDateFieldStyle> builder, FFieldIconBuilder<FTextFieldStyle> ? prefixBuilder, FFieldIconBuilder<FTextFieldStyle> ? suffixBuilder, Widget? label, Widget? description, bool enabled, FormFieldSetter<DateTime> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext context, String message), Key? formFieldKey, Key? key}) -
Creates a FDateField that allows a date to be selected using only a calendar.
constfactory
-
FDateField.input({FDateFieldControl control, FTextFieldSizeVariant size, FDateFieldStyleDelta style, bool autofocus, FocusNode? focusNode, FFieldBuilder<
FDateFieldStyle> builder, FFieldIconBuilder<FTextFieldStyle> ? prefixBuilder, FFieldIconBuilder<FTextFieldStyle> ? suffixBuilder, TextInputAction? textInputAction, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, VoidCallback? onEditingComplete, ValueChanged<DateTime> ? onSubmit, MouseCursor? mouseCursor, bool canRequestFocus, bool clearable, int baselineInputYear, Widget? label, Widget? description, bool enabled, FormFieldSetter<DateTime> ? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext context, String message), Key? formFieldKey, Key? key}) -
Creates a date field that wraps a text input field.
constfactory
Properties
- autofocus → bool
-
True if this widget will be selected as the initial focus when no other node in its scope is currently focused.
final
- autovalidateMode → AutovalidateMode
-
Used to enable/disable this checkbox auto validation and update its error text.
final
-
builder
→ FFieldBuilder<
FDateFieldStyle> -
The builder used to decorate the date-field. It should use the given child.
final
- control → FDateFieldControl
-
The control for managing the date field's state.
final
- description → Widget?
-
The description.
final
- enabled → bool
-
Whether the form is able to receive user input.
final
- errorBuilder → Widget Function(BuildContext context, String message)
-
The builder for errors displayed below the description. Defaults to displaying the error message.
final
- focusNode → FocusNode?
-
An optional focus node to use as the focus node for this widget.
final
- forceErrorText → String?
-
An optional property that forces the FormFieldState into an error state by directly setting the
FormFieldState.errorText property without running the validator function.
final
- formFieldKey → Key?
-
The key to use for the internal FormField.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → Widget?
-
The label.
final
- onReset → VoidCallback?
-
An optional method to call when the form field is reset via FormFieldState.reset.
final
-
onSaved
→ FormFieldSetter<
DateTime> ? -
An optional method to call with the final value when the form is saved via FormState.save.
final
-
prefixBuilder
→ FFieldIconBuilder<
FTextFieldStyle> ? -
Builds a widget at the start of the input field that can be pressed to toggle the calendar popover. Defaults to
defaultIconBuilder.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → FTextFieldSizeVariant
-
The text field's size variant. Defaults to FTextFieldSizeVariant.md.
final
- style → FDateFieldStyleDelta
-
The style.
final
-
suffixBuilder
→ FFieldIconBuilder<
FTextFieldStyle> ? -
Builds a widget at the end of the input field that can be pressed to toggle the calendar popover. Defaults to
no prefix.
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.
inherited
-
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.
override
-
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
Static Methods
-
defaultIconBuilder(
BuildContext context, FTextFieldStyle style, Set< FTextFieldVariant> variants) → Widget - The default prefix builder that shows a calendar icon.