ZdsCalendar class

An adaptable calendar widget that can be used in a variety of ways, with selectable days and date ranges, as well as event markers and different formats.

Extended from TableCalendar.

This calendar has three variants, each called with a different constructor:

  • ZdsCalendar, which allows to switch between a monthly and weekly format. It always has a header with the current month and a format switcher.
  • ZdsCalendar.monthly, which shows a calendar with a fixed month format.
  • ZdsCalendar.weekly, which shows a calendar with a fixed week format.

For this widget, the selectedDay refers to the day currently selected (i.e., with a filled circle surrounding it), while TableCalendar.focusedDay refers to the day that is currently in focus (i.e., shown on screen). The TableCalendar.focusedDay has no special decoration and looks like any other day. The selectedDay may not be the TableCalendar.focusedDay and may not be displayed on screen (e.g. the user selects a day on February and changes the month to March, making selectedDay a day in February and TableCalendar.focusedDay a day in March).

Several callback functions are available to sync other widgets with this one. These are onDaySelected, onRangeSelected, and onPageChanged.

Inheritance
Available Extensions

Constructors

ZdsCalendar({required List<CalendarEvent> events, Key? key, bool showAllButton = false, void onAllSelected(DateTime?, DateTime?, DateTime)?, DateTime? firstDay, DateTime? lastDay, DateTime? initialSelectedDay, DateTime? selectedDay, StartingDayOfWeek? startingDayOfWeek, DateTime? initialSelectedWeek, List<WeekIcon>? weekIcons, bool isRangeSelectable = false, bool isGridShown = false, void onDaySelected(DateTime, DateTime)?, void onRangeSelected(DateTime?, DateTime?, DateTime)?, void onPageChanged(DateTime)?, void onFormatChanged(CalendarFormat)?, EdgeInsets headerPadding = const EdgeInsets.fromLTRB(4, 8, 8, 8), Widget? singleMarkerBuilder(BuildContext, DateTime, dynamic)?, AvailableGestures availableGestures = AvailableGestures.horizontalSwipe, bool enabled = true, Color? calendarHeaderIconColor, Color? calendarHeaderTextColor, Color? calendarTextColor, List<DateTime> holidayEvents = const [], String? allCustomLabel, double? calendarRowHeight, String? previousTooltip, String? nextTooltip})
Calendar widget that allows to switch between a monthly and weekly format. As such, the calendar header will always be shown. To not show the calendar header and use a monthly format, use ZdsCalendar.monthly instead.
const
ZdsCalendar.monthly({required List<CalendarEvent> events, Key? key, bool showAllButton = false, void onAllSelected(DateTime?, DateTime?, DateTime)?, DateTime? firstDay, DateTime? lastDay, DateTime? initialSelectedDay, DateTime? selectedDay, StartingDayOfWeek? startingDayOfWeek, DateTime? initialSelectedWeek, bool hasHeader = true, List<WeekIcon>? weekIcons, bool isRangeSelectable = false, bool isGridShown = false, void onDaySelected(DateTime, DateTime)?, void onRangeSelected(DateTime?, DateTime?, DateTime)?, void onPageChanged(DateTime)?, void onFormatChanged(CalendarFormat)?, EdgeInsets headerPadding = const EdgeInsets.fromLTRB(4, 8, 8, 8), Widget? singleMarkerBuilder(BuildContext, DateTime, dynamic)?, AvailableGestures availableGestures = AvailableGestures.horizontalSwipe, bool enabled = true, Color? calendarHeaderIconColor, Color? calendarHeaderTextColor, Color? calendarTextColor, List<DateTime> holidayEvents = const [], String? allCustomLabel, double? calendarRowHeight, String? previousTooltip, String? nextTooltip})
Shows a calendar in a fixed monthly format.
const
ZdsCalendar.weekly({required List<CalendarEvent> events, Key? key, bool showAllButton = false, void onAllSelected(DateTime?, DateTime?, DateTime)?, DateTime? firstDay, DateTime? lastDay, DateTime? initialSelectedDay, DateTime? selectedDay, StartingDayOfWeek? startingDayOfWeek, DateTime? initialSelectedWeek, bool isRangeSelectable = false, bool isGridShown = false, List<WeekIcon>? weekIcons, void onDaySelected(DateTime, DateTime)?, void onRangeSelected(DateTime?, DateTime?, DateTime)?, void onPageChanged(DateTime)?, void onFormatChanged(CalendarFormat)?, EdgeInsets headerPadding = const EdgeInsets.fromLTRB(4, 8, 8, 8), Widget? singleMarkerBuilder(BuildContext, DateTime, dynamic)?, AvailableGestures availableGestures = AvailableGestures.horizontalSwipe, bool enabled = true, Color? calendarHeaderIconColor, Color? calendarHeaderTextColor, Color? calendarTextColor, List<DateTime> holidayEvents = const [], String? allCustomLabel, double? calendarRowHeight, String? previousTooltip, String? nextTooltip})
Shows a calendar in a fixed weekly format.
const

Properties

allCustomLabel String?
Label will be shown for all button.
final
availableGestures AvailableGestures
Specifies swipe gestures available to TableCalendar.
final
calendarHeaderIconColor Color?
Color of the chevron icons on the calendar header
final
calendarHeaderTextColor Color?
Color of the text on the calendar header
final
calendarRowHeight double?
an override for calendar row height
final
calendarTextColor Color?
Custom color override for unselected days.
final
enabled bool
True if component is enabled and editable, false if read only.
final
events List<CalendarEvent>
A list with events. Can't be null. If markers are enabled, these events will be displayed on the calendar.
final
firstDay DateTime?
The earliest date that will be shown on the calendar.
final
hashCode int
The hash code for this object.
no setterinherited
hasHeader bool
Whether the header should be shown or not. If using the ZdsCalendar constructor, the header will contain a format switcher. To not show a format switcher, use ZdsCalendar.monthly instead.
final
headerPadding EdgeInsets
Padding around the header of the calendar
final
holidayEvents List<DateTime>
A list of holiday dates. holiday will be shown on calendar with grey circle.
final
initialSelectedDay DateTime?
set initial selected Date on the calendar
final
initialSelectedWeek DateTime?
set initial selected week on the calendar
final
isGridShown bool
Whether to show a grid. Defaults to false.
final
isRangeSelectable bool
Whether you can only select one unique day or can select a range of days. Defaults to false.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lastDay DateTime?
The last date that will be shown on the calendar.
final
nextTooltip String?
Tooltip for the next month button
final
onAllSelected → (void Function(DateTime?, DateTime?, DateTime)?)
Function called whenever a all option is selected. Takes three arguments, the starting day, the ending day, and the focusedDay. The starting and end day can be null.
final
onDaySelected → (void Function(DateTime, DateTime)?)
Function called whenever the selected day changes. Takes two arguments, the selectedDay and the focusedDay.
final
onFormatChanged → (void Function(CalendarFormat)?)
Called whenever the format of the calendar is changed. Takes one argument, the new calendar format.
final
onPageChanged → (void Function(DateTime)?)
Called whenever the user changes page. Takes one argument, the focused day.
final
onRangeSelected → (void Function(DateTime?, DateTime?, DateTime)?)
Function called whenever a date range is selected. Takes three arguments, the starting day, the ending day, and the focusedDay. The starting and end day can be null.
final
previousTooltip String?
Tooltip for the previous month button
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedDay DateTime?
set and manage the selected day on the calendar. Will override intialSelectedDay.
final
showAllButton bool
This enables all button to select current week of the calendar, Defaults to false.
final
singleMarkerBuilder → (Widget? Function(BuildContext, DateTime, dynamic)?)
Function that creates a single event marker for a given day
final
startingDayOfWeek StartingDayOfWeek?
set Starting Day Of the week on the calendar
final
weekIcons List<WeekIcon>?
List of icons to be shown at the beginning of selected weeks.
final

Methods

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