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:

Inheritance

Constructors

FDateField.new({FDateFieldController? controller, FDateFieldStyle? style, DateTime? initialDate, 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, int baselineInputYear, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)> builder, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder, FDateFieldCalendarProperties calendar, Widget? label, Widget? description, bool enabled, ValueChanged<DateTime?>? onChange, FormFieldSetter<DateTime>? onSaved, AutovalidateMode autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext, String), Key? key})
Creates a FDateField that allows date selection through both an input field and a calendar popover.
factory
FDateField.calendar({FDateFieldController? controller, FDateFieldStyle? style, DateTime? initialDate, DateFormat? format, TextAlign textAlign, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands, MouseCursor mouseCursor, bool canRequestFocus, bool clearable, String? hint, bool autofocus, FocusNode? focusNode, ValueWidgetBuilder<FCalendarDayData> dayBuilder, DateTime? start, DateTime? end, DateTime? today, FCalendarPickerType initialType, bool autoHide, Alignment anchor, Alignment inputAnchor, FPortalSpacing spacing, Offset shift(Size, FPortalChildBox, FPortalBox), Offset offset, FHidePopoverRegion hideOnTapOutside, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)> builder, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder, Widget? label, Widget? description, bool enabled, ValueChanged<DateTime?>? onChange, FormFieldSetter<DateTime>? onSaved, AutovalidateMode autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext, String), Key? key})
Creates a FDateField that allows a date to be selected using only a calendar.
factory
FDateField.input({FDateFieldController? controller, FDateFieldStyle? style, DateTime? initialDate, bool autofocus = false, FocusNode? focusNode, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)> builder = _fieldBuilder, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>? prefixBuilder = defaultIconBuilder, ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>? suffixBuilder, TextInputAction? textInputAction, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool expands = false, VoidCallback? onEditingComplete, ValueChanged<DateTime>? onSubmit, MouseCursor? mouseCursor, bool canRequestFocus = true, bool clearable = false, int baselineInputYear = 2000, Widget? label, Widget? description, bool enabled = true, ValueChanged<DateTime?>? onChange, FormFieldSetter<DateTime>? onSaved, AutovalidateMode autovalidateMode = AutovalidateMode.onUnfocus, String? forceErrorText, Widget errorBuilder(BuildContext, String) = FFormFieldProperties.defaultErrorBuilder, 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 ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>
The builder used to decorate the date-field. It should use the given child.
final
controller FDateFieldController?
The controller.
final
description Widget?
The description.
final
enabled bool
Whether the form is able to receive user input.
final
errorBuilder Widget Function(BuildContext, String)
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
hashCode int
The hash code for this object.
no setterinherited
initialDate DateTime?
The initial date.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label Widget?
The label.
final
onChange ValueChanged<DateTime?>?
Handler called when the date changes.
final
onSaved FormFieldSetter<DateTime>?
An optional method to call with the final value when the form is saved via FormState.save.
final
prefixBuilder ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>?
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
style FDateFieldStyle?
The style.
final
suffixBuilder ValueWidgetBuilder<(FDateFieldStyle, FTextFieldStyle, Set<WidgetState>)>?
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 _, (FDateFieldStyle, FTextFieldStyle, Set<WidgetState>) styles, Widget? _) Widget
The default prefix builder that shows a calendar icon.