WeDatePicker class
A date field with a drop-down calendar, after el-date-picker.
WeDatePicker(
value: due,
onChanged: (d) => setState(() => due = d),
)
WeDatePicker.range(
range: period,
onChanged: (r) => setState(() => period = r),
shortcuts: [
WeDateShortcut('最近一周', () => DateTimeRange(
start: DateTime.now().subtract(const Duration(days: 6)),
end: DateTime.now(),
)),
],
)
Made for a keyboard as much as for a mouse. The field takes typing:
2026-9-5, 2026/09/05 or 20260905 all work, the panel follows as you
type, Enter commits and an unreadable entry reverts when the field loses
focus. ↓ moves into the panel, which then works like WeDatePanel; Escape
closes it. In a range, Enter in the start field moves on to the end field.
Inside a WeFormItem it picks up the item's size, disabled state and error colour, and reports changes and blur for validation.
On touch it opens a WeDateSheet (spinning year, month and day columns from the bottom) instead of the panel, and the field stops taking typing so no keyboard pops up. Set touchMode to WeDatePickerTouchMode.panel to keep the panel.
Platform: universal; desktop gets the panel, touch gets the sheet.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- WeDatePicker
Constructors
-
WeDatePicker({Key? key, required DateTime? value, required ValueChanged<
DateTime?> ? onChanged, String? hint, String format = 'yyyy-MM-dd', bool editable = true, bool clearable = true, bool disabled = false, SizeEnum size = SizeEnum.defaultSize, double? width = 220, SemanticEnum? status, DateTime? firstDate, DateTime? lastDate, bool disabledDate(DateTime day)?, int? firstDayOfWeek, bool showWeekNumber = false, WeDateLocale locale = WeDateLocale.zh, List<WeDateShortcut< shortcuts = const [], WePlacement placement = WePlacement.bottomStart, WeDatePickerTouchMode touchMode = WeDatePickerTouchMode.sheet})DateTime> > -
Picks one day.
const
-
WeDatePicker.range({Key? key, required DateTimeRange<
DateTime> ? range, required ValueChanged<DateTimeRange< ? onChanged, String? startHint, String? endHint, String format = 'yyyy-MM-dd', bool editable = true, bool clearable = true, bool disabled = false, SizeEnum size = SizeEnum.defaultSize, double? width = 360, SemanticEnum? status, DateTime? firstDate, DateTime? lastDate, bool disabledDate(DateTime day)?, int? firstDayOfWeek, bool showWeekNumber = false, WeDateLocale locale = WeDateLocale.zh, List<DateTime> ?>WeDateShortcut< shortcuts = const [], WePlacement placement = WePlacement.bottomStart, WeDatePickerTouchMode touchMode = WeDatePickerTouchMode.sheet})DateTimeRange< >DateTime> > -
Picks a start and an end day.
const
Properties
- clearable → bool
-
final
- disabled → bool
-
final
- disabledDate → bool Function(DateTime day)?
-
final
- editable → bool
-
Allow typing a date into the field. When
falsethe field only opens the panel.final - endHint → String?
-
final
- firstDate → DateTime?
-
final
- firstDayOfWeek → int?
-
final
- format → String
-
How the field shows a day and reads it back; see weFormatDate.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hint → String?
-
Placeholder; defaults to the locale's.
final
- isRange → bool
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- lastDate → DateTime?
-
final
- locale → WeDateLocale
-
final
-
onChanged
→ ValueChanged<
DateTime?> ? -
Receives the new day, or
nullwhen cleared.final -
onRangeChanged
→ ValueChanged<
DateTimeRange< ?DateTime> ?> -
final
- placement → WePlacement
-
final
-
range
→ DateTimeRange<
DateTime> ? -
final
-
rangeShortcuts
→ List<
WeDateShortcut< DateTimeRange< >DateTime> > -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shortcuts
→ List<
WeDateShortcut< DateTime> > -
Presets listed beside the panel.
final
- showWeekNumber → bool
-
final
- size → SizeEnum
-
final
- startHint → String?
-
final
- status → SemanticEnum?
-
Colours the border; a surrounding WeFormItem sets it on error.
final
- touchMode → WeDatePickerTouchMode
-
What a tap opens on touch platforms; see WePlatform.isTouch.
final
- value → DateTime?
-
final
- width → double?
-
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< WeDatePicker> -
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