Calendar
A Flutter calendar widget with customizable initial date and date selection callback.
Introduction
FluttyCalendar is a simple yet powerful calendar widget implemented in Flutter. It allows users to navigate through months, view days in a grid, and select a specific date. The selected date can be accessed using a callback, and the initial date can be set programmatically.
Usage
Basic Calendar
FluttyCalendar(
initialDate: DateTime.now(),
onDateSelected: (date) {
print("Selected date: $date");
},
);Calendar with a Preset Date
FluttyCalendar(
initialDate: DateTime(2023, 3, 15),
onDateSelected: (date) {
print("Selected: $date");
},
);API
FluttyCalendar Props
| Prop | Type | Default |
|---|---|---|
initialDate? | DateTime? | null |
onDateSelected? | ValueChanged<DateTime>? | null |
Features
1. Month Navigation
Users can navigate between months using the left and right arrow buttons in the header. The displayed month's name is formatted with Intl for a localized experience.
2. Day Grid
The calendar displays days in a grid format with each row representing a week. Days from the current month are tappable, while cells for days outside the current month are left empty.
3. Selected Date
When a user taps a date, it is highlighted, and the onDateSelected callback is triggered with the selected date.
4. Today Indicator
Today's date is lightly highlighted with a blue background and bold text, making it stand out visually.
Notes
- If
initialDateis not provided, the calendar defaults to the current month and year. - Users can navigate to any month using the arrow buttons (no constraints on min/max months).
- The
onDateSelectedcallback is optional. If not provided, date selection simply updates the UI without additional behavior.