ZdsDateRange class

A date range selector that also allows to quickly change the range selected by jumping to the next or previous set of dates.

This component is typically used as the title of a ZdsToolbar, allowing to switch the body's content depending on the selected range.

ZdsToolbar(
  title: DateRange(
    emptyLabel: 'Select range',
    actions: [
      ZdsButton.text(
        child: const Text('Fiscal View'),
        onTap: () {},
      ),
    ],
  ),
)

When no range has been selected, the emptyLabel text will be shown. Tapping on this opens a full-screen date range selector. Once the date range has been selected, it will be shown on the component.

The user can quickly jump forwards and backwards by pressing on the chevron icon buttons. For example, if the date range is March 1 - March 5, the previous date range will be February 24 - February 28, and the next one will be March 6 - March 10. You can keep track of these changes with onChange.

See also:

Inheritance
Available Extensions

Constructors

ZdsDateRange({Key? key, DateTime? firstDate, DateTime? lastDate, DateTimeRange? initialDateRange, void onChange(DateTimeRange?)?, List<Widget>? actions, String emptyLabel = '', TextStyle? textStyle, String? clearButtonString, String? applyButtonString, bool isSelectable = true, String dateRangeSeparator = '-', String? nextTooltip, String? previousTooltip, bool isWeekMode = false, int startDayOfWeek = 0, String? dateFormat})
Creates a date range selector.
const

Properties

actions List<Widget>?
Widgets shown when choosing a date range for additional actions other than clearing and applying.
final
applyButtonString String?
The string to use for the apply range button.
final
clearButtonString String?
The string to use for the clear range button.
final
dateFormat String?
to change date format of date range
final
dateRangeSeparator String
Used as a date range separator
final
emptyLabel String
The empty label to show when no date has been chosen.
final
firstDate DateTime?
The earliest date that can be chosen for the range.
final
hashCode int
The hash code for this object.
no setterinherited
initialDateRange DateTimeRange?
The initial date range to show when first building this widget.
final
isSelectable bool
Used for making the dateRange clickable
final
isWeekMode bool
If true, user can only select weeks, not days in popup.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lastDate DateTime?
The last date that can be chosen for the range.
final
nextTooltip String?
Tooltip to go with the next icon.
final
onChange → (void Function(DateTimeRange?)?)
Callback function called whenever the selected date range changes.
final
previousTooltip String?
Tooltip to go with the previous icon.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startDayOfWeek int
0 indexed where Sunday is 0 and Saturday is 6
final
textStyle TextStyle?
The textStyle to use for the button to open the date range selector.
final

Methods

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