DatePicker class

The date picker gives you a standardized way to let users pick a localized date value using touch, mouse, or keyboard input. Use a date picker to let a user pick a known date, such as a date of birth, where the context of the calendar is not important.

DatePicker Preview

See also:

Inheritance

Constructors

DatePicker({Key? key, required DateTime selected, ValueChanged<DateTime>? onChanged, VoidCallback? onCancel, String? header, TextStyle? headerStyle, bool showDay = true, bool showMonth = true, bool showYear = true, int? startYear, int? endYear, EdgeInsetsGeometry contentPadding = kPickerContentPadding, double popupHeight = kPopupHeight, MouseCursor cursor = SystemMouseCursors.click, FocusNode? focusNode, bool autofocus = false})
const

Properties

autofocus bool
Whenever autofocus is enabled or not
final
contentPadding EdgeInsetsGeometry
The padding of the picker. Defaults to kPickerContentPadding
final
cursor MouseCursor
The cursor of the picker. Defaults to SystemMouseCursors.click
final
endYear int?
The year to end the counting. If null, defaults to date's year + 25
final
focusNode FocusNode?
The focus node of the picker.
final
hashCode int
The hash code for this object.
no setterinherited
The header of the picker
final
headerStyle TextStyle?
The style of the header
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onCancel VoidCallback?
Whenever the user cancels when changing the date.
final
onChanged ValueChanged<DateTime>?
Whenever the current date is changed. If this is null, the picker is considered disabled
final
popupHeight double
The height of the popup. Defaults to kPopupHeight
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selected DateTime
The current date.
final
showDay bool
Whenever to show the day property
final
showMonth bool
Whenever to show the month property
final
showYear bool
Whenever to show the year property
final
startYear int?
The year to start counting from. If null, defaults to date's year - 100
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _DatePickerState
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.
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}) 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