HorizontalWeekCalendar class
Horizontal scrollable week calendar with date selection.
A customizable weekly calendar widget that displays one week at a time in a horizontal carousel. Supports infinite scrolling with min/max date constraints, customizable colors, and optional navigation buttons.
Features:
- Carousel-based week scrolling (swipe or navigation buttons)
- Configurable start day (Monday or Sunday)
- Date selection with callbacks
- Week change callbacks
- Customizable colors for active/inactive/disabled states
- Min/max date constraints with automatic boundary handling
- Optional navigation buttons
- Customizable month format display
- Automatic week generation (lazy loading)
- Responsive layout with equal-width date cells
Example:
HorizontalWeekCalendar(
minDate: DateTime(2024, 1, 1),
maxDate: DateTime(2024, 12, 31),
initialDate: DateTime.now(),
weekStartFrom: WeekStartFrom.monday,
activeBackgroundColor: Colors.blue,
inactiveBackgroundColor: Colors.blue.withOpacity(0.2),
onDateChange: (date) {
print('Selected date: $date');
},
onWeekChange: (weekDates) {
print('Week from ${weekDates.first} to ${weekDates.last}');
},
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- HorizontalWeekCalendar
- Available extensions
Constructors
-
HorizontalWeekCalendar({Key? key, dynamic onDateChange(DateTime)?, dynamic onWeekChange(List<
DateTime> )?, Color? activeBackgroundColor, Color? inactiveBackgroundColor, Color? disabledBackgroundColor = Colors.grey, Color? activeTextColor = Colors.white, Color? inactiveTextColor = Colors.white, Color? disabledTextColor = Colors.white, Color? monthColor, WeekStartFrom? weekStartFrom = WeekStartFrom.monday, BorderRadiusGeometry? borderRadius, ScrollPhysics? scrollPhysics = const ClampingScrollPhysics(), String? monthFormat, required DateTime minDate, required DateTime maxDate, required DateTime initialDate, }) - Creates a HorizontalWeekCalendar widget.
Properties
- activeBackgroundColor → Color?
-
Background color for the selected/active date.
final
-
Color for enabled navigation buttons.
final
- activeTextColor → Color?
-
Text color for the selected/active date.
final
- borderRadius → BorderRadiusGeometry?
-
Border radius for date card decoration.
final
- disabledBackgroundColor → Color?
-
Background color for disabled dates (outside min/max range).
final
- disabledTextColor → Color?
-
Text color for disabled dates.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- inactiveBackgroundColor → Color?
-
Background color for unselected/inactive dates within valid range.
final
-
Color for disabled navigation buttons.
final
- inactiveTextColor → Color?
-
Text color for unselected/inactive dates.
final
- initialDate → DateTime
-
Initially selected and displayed date.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- marginZero → Widget
-
Available on Widget, provided by the WidgetMarginX extension
no setter - maxDate → DateTime
-
Maximum selectable date (inclusive).
final
- minDate → DateTime
-
Minimum selectable date (inclusive).
final
- monthColor → Color?
-
Color for the month/year header text.
final
- monthFormat → String?
-
Date format string for the month/year header.
final
- onDateChange → dynamic Function(DateTime)?
-
Callback invoked when a date is selected.
final
-
onWeekChange
→ dynamic Function(List<
DateTime> )? -
Callback invoked when the displayed week changes.
final
- paddingZero → Widget
-
Available on Widget, provided by the WidgetPaddingX extension
no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollPhysics → ScrollPhysics?
-
Scroll physics for the carousel.
final
-
Show/hide navigation buttons (Back/Next).
final
-
Show/hide the top navigation bar (month header and nav buttons).
final
- sliverBox → Widget
-
Available on Widget, provided by the WidgetSliverBoxX extension
no setter - weekStartFrom → WeekStartFrom?
-
Week start day preference.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< HorizontalWeekCalendar> -
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
-
marginAll(
double margin) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
marginSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetMarginX extension
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
paddingAll(
double padding) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingOnly(
{double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
paddingSymmetric(
{double horizontal = 0.0, double vertical = 0.0}) → Widget -
Available on Widget, provided by the WidgetPaddingX extension
-
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