Flutter FlexiCalendar
The Custom Calendar package is a flexible and highly customizable date picking library natively written in Dart for creating beautiful and high-performance calendar views, which are used to craft high-quality mobile app user interfaces using Flutter.
Overview
Create various types of calendar views with seamless interaction, responsiveness, and smooth scrolling. It has a rich set of features, and it is completely customizable and extendable.
This flexi_calendar package includes the following primary widget:
FlexiCalendar
Table of contents
- Calendar features
- Installation
- Calendar getting started
- Add calendar to the widget tree
- Bind configuration
- Add event elements
- Support and Feedback
Calendar features
-
Selection Modes - Provides functionality for Single date selection, Date Range selection, and Multiple independent dates selection.
-
Views - Plot various amounts of days in the graph with the help of Month view and Week view.
-
User interaction - The end-user experience is greatly enhanced by including horizontal swipe gestures to smoothly navigate between different months or weeks based on the selected view.
-
Date Constraints - Prevent selection of invalid dates dynamically with
firstDate,lastDate,disablePastDates, anddisableFutureDates. -
Custom Builders - Wrap the Header and Body of the calendar inside your own custom containers with full programmatic layout integration.
Installation
Install the latest version from your pubspec.yaml dependencies:
dependencies:
flexi_calendar: ^0.0.1
Calendar getting started
Import the following package.
import 'package:flexi_calendar/flexi_calendar.dart';
Add calendar to the widget tree
Add the calendar widget as a child of any widget. Here, the calendar widget is added as a child of container widget.
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: FlexiCalendar()
)
)
);
}
Bind configuration
Based on data, initialize the appropriate config type for selection modes, first dates, and max dates.
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: FlexiCalendar(
config: CalendarConfig(
firstDate: DateTime(2020),
lastDate: DateTime(2030),
selectionMode: CalendarSelectionMode.range,
themeColor: Colors.blue,
),
onRangeSelected: (range) {
print("Selected Range: ${range.start} - ${range.end}");
},
)
)
)
);
}
Add event elements
Add the calendar event elements such as dots to display additional information about the date plotted in the calendar.
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
child: FlexiCalendar(
config: CalendarConfig(
firstDate: DateTime(2020),
lastDate: DateTime(2030),
),
events: {
DateTime(2026, 2, 3): [
CalendarEvent(color: Colors.red),
CalendarEvent(color: Colors.green),
],
DateTime(2026, 2, 10): [
CalendarEvent(color: Colors.blue),
],
},
)
)
)
);
}
Additional Configurations (CalendarConfig)
You can pass the following parameters to CalendarConfig for further customization:
| Parameter | Type | Default | Description |
|---|---|---|---|
firstDate |
DateTime |
Required | The earliest acceptable date in the calendar. |
lastDate |
DateTime |
Required | The latest acceptable date in the calendar. |
selectionMode |
CalendarSelectionMode |
.single |
.single, .range, or .multiple. |
calendarView |
CalendarView |
.month |
Toggle between .month and .week. |
autoSelectToday |
bool |
false |
Automatically highlights today's date on initialized. |
disablePastDates |
bool |
false |
Greys out dates before today. |
disableFutureDates |
bool |
false |
Greys out dates after today. |
startWeekOn |
int |
DateTime.sunday |
Which day the week starts on. |
allowSwipe |
bool |
true |
Navigates between months/weeks with gestures. |
themeColor |
Color? |
null |
Theme color for selected day highlights. |
textStyles |
CalendarTextStyles |
Default | Allows deep styling of headers and day views. |
Support and Feedback
- For any other queries, submit a feature request or a bug through our GitHub repository.
License
Libraries
- flexi_calendar
- Main library export file for the custom_calendar package.