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 (پښتو)

Consider providing a validator to perform custom date validation logic. By default, all dates are valid.

See:

Inheritance

Constructors

FDateField({FDateSelectionControl<DateTime?>? selectionControl, 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, FFieldClearIconBuilder<FTextFieldStyle> clearIconBuilder, int baselineInputYear, FDateFieldCalendarProperties calendar, FFieldBuilder<FDateFieldStyle> builder, FFieldIconBuilder<FTextFieldStyle>? prefixBuilder, FFieldIconBuilder<FTextFieldStyle>? suffixBuilder, Widget? label, Widget? description, bool enabled, FormFieldSetter<DateTime>? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<DateTime> validator, 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.
factory
FDateField.calendar({FDateSelectionControl<DateTime?>? selectionControl, FPopoverControl popoverControl, FTextFieldSizeVariant size, FDateFieldStyleDelta style, String format(BuildContext context, DateTime value, DateFormat format), TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, FFieldClearIconBuilder<FTextFieldStyle> clearIconBuilder, String? hint, bool autofocus, FocusNode? focusNode, FDateFieldCalendarProperties calendar, FFieldBuilder<FDateFieldStyle> builder, FFieldIconBuilder<FTextFieldStyle>? prefixBuilder, FFieldIconBuilder<FTextFieldStyle>? suffixBuilder, Widget? label, Widget? description, bool enabled, FormFieldSetter<DateTime>? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<DateTime> validator, Widget errorBuilder(BuildContext context, String message), Key? formFieldKey, Key? key})
Creates a FDateField that allows a date to be selected using only a calendar.
factory
FDateField.input({FDateSelectionControl<DateTime?>? selectionControl, 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, FFieldClearIconBuilder<FTextFieldStyle> clearIconBuilder, int baselineInputYear, Widget? label, Widget? description, bool enabled, FormFieldSetter<DateTime>? onSaved, VoidCallback? onReset, AutovalidateMode autovalidateMode, String? forceErrorText, FormFieldValidator<DateTime> validator, Widget errorBuilder(BuildContext context, String message), Key? formFieldKey, Key? key})
Creates a date field that wraps a text input field.
factory

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
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
selectionControl → FDateSelectionControl<DateTime?>
The control for managing the date field's selected date. Defaults to FDateSelectionControl.managedSingle.
final
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
validator → FormFieldValidator<DateTime>
Returns an error string to display if the input is invalid, or null otherwise.
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

defaultFormat(BuildContext context, DateTime value, DateFormat format) → String
The default format for FDateField.calendar, which formats value using format.
defaultIconBuilder(BuildContext context, FTextFieldStyle style, Set<FTextFieldVariant> variants) → Widget
The default prefix builder that shows a calendar icon.
defaultValidator(DateTime? _) → String?
The default validator that always returns null, indicating all dates are valid.