ZdsDateTimePicker class
A widget that allow to select a date, a time, or both.
A controller can be used to handle this date and use it to manage state.
This widget is typically used as a non-editable text field by using ZdsInputDecoration for inputDecoration. It can also be used as a button on its own by not assigning any inputDecoration.
// As a text field
ZdsDateTimePicker(
emptyLabel: 'select date',
minDate: DateTime.now(),
mode: DateTimePickerMode.date,
controller: _controller,
inputDecoration: ZdsInputDecoration(
labelText: 'Optional Date',
suffixIcon: IconButton(
icon: const Icon(ZdsIcons.close_circle, size: 24,),
onPressed: () => _controller.value = null,
),
),
onChange: (dateTime) => handleTime(dateTime),
),
// As a button
ZdsDateTimePicker(
emptyLabel: 'select time',
textAlign: TextAlign.center,
minDate: DateTime.now(),
mode: DateTimePickerMode.time,
),
See also:
- ZdsDateRangePickerTile, which allows to select a date range's start and end time separately.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ZdsDateTimePicker
- Available Extensions
Constructors
-
ZdsDateTimePicker({required String emptyLabel, Key? key, String? format, DateTimePickerMode mode = DateTimePickerMode.date, TextAlign textAlign = TextAlign.start, String? helpText, TextStyle? helpTextStyle, DateTime? minDate, DateTime? maxDate, DateTime? selectedDate, TextStyle? textStyle, void onChange(DateTime? dateTime)?, EdgeInsets? padding, InputDecoration? inputDecoration, ZdsValueController<
DateTime> ? controller, bool readOnly = false, int? interval, VisibleStep visibleStep = interval_picker.VisibleStep.fifths, String? timePickerErrorText, bool? use24HourFormat, TimePickerEntryMode timePickerEntryMode = TimePickerEntryMode.inputOnly, String? okClickText, String? cancelClickText, int? startDayOfWeek}) - Constructs a ZdsDateTimePicker.
Properties
- cancelClickText → String?
-
The text displayed on the cancel button.
final
-
controller
→ ZdsValueController<
DateTime> ? -
A controller used to keep track of the selected date.
final
- emptyLabel → String
-
Text that will appear when no date has been selected.
final
- format → String
-
The format in which the DateTime will be formatted.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- helpText → String?
-
The text displayed at the top of the date picker window.
final
- helpTextStyle → TextStyle?
-
The style applied to the help text. Defaults to Theme.of(context).textTheme.labelSmall.
final
- inputDecoration → InputDecoration?
-
Optional decoration for this widget.
final
- interval → int?
-
The interval that the picker will step up in. Only valid for time pickers.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- maxDate → DateTime?
-
The latest date that can be selected. Must be after minDate.
final
- minDate → DateTime?
-
The earliest date that can be selected. Must be before the maxDate.
final
- mode → DateTimePickerMode
-
The type of picker to show -
date
,time
ordateAndTime
.final - okClickText → String?
-
The text displayed on the ok button.
final
- onChange → (void Function(DateTime? dateTime)?)
-
A function called whenever the date or time selected has changed.
final
- padding → EdgeInsets?
-
Empty space to surround this widget.
final
- readOnly → bool
-
to enable the click of calendar icon.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedDate → DateTime?
-
A pre-selected date.
final
- startDayOfWeek → int?
-
Starting day of week 1, 2, 3, Sunday, Monday, Tuesday respectively.
final
- textAlign → TextAlign
-
How the text will be aligned in this widget.
final
- textStyle → TextStyle?
-
The style used for this button's or field's appearance.
final
- timePickerEntryMode → TimePickerEntryMode
-
Initial entry mode for time pickers.
final
- timePickerErrorText → String?
-
The error text used on the time picker.
final
- use24HourFormat → bool?
-
Overrides the 24 hour format of the locale.
final
- visibleStep → VisibleStep
-
The minute labels that are visible on the ring of the picker. Only valid for time pickers.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → ZdsDateTimePickerState -
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