Smart_Calendar is a library that show the calendar, with the possibility of selecting multiples days, change the month or year with simple dynamic.
- Predefined title widget that returns the calendar month and year.
- Customizable title widget.
- Possibility to change the month with horizontal sliding gesture.
- Brings an extra calendar for the months and year as a cafeteria, which can be reached by clicking on the title widget.
- The user can select multiple days.
- Returns the list of selected dates and returns the current month and year every time it changes.
- Now it's possible to add a list of events dates with they title and description, check the example below to know how to do it.
- The list of events can be annual or not.
- Solved the bug that was letting select the past dates.
- Please use the example below of events dates to add events to your calendar, remember to add all parameters, the day and month are waiting for two digits, so, if the months is 1, then will be 01, the same for the day.
- First you have to set the controller, where you have to set the initial and last date, the language, the calendar type and weekday type.
final controller = SmartCalendarController(
initialDate: DateTime.now(),
lastDate: DateTime.utc(2053, 04, 31),
eventDates: [
{
"date": "2021-05-01",
"description": "This a holiday because of the Worker day",
"title": "Worker Day"
},
{
"date": "2021-06-01",
"description": "This a holiday because of the Kids day",
"title": "Kids Day"
},
{
"date": "2021-09-17",
"description": "This a holiday because of the hero day",
"title": "Hero day"
}
],
annualEvents: false,
locale: 'en_US',
calendarType: CalendarType.civilCalendar,
weekdayType: WeekDayType.medium,
);
- After this you can call the class and add the functions that you want to return.
SmartCalendar(
controller: controller,
onBackwardOrForward: (month, year) {
setState(() {
this.month = month;
this.year = year;
});
print('This $month and this $year');
},
onDayAddedOrRemoved: (day, month, monthName, year, dates) {
print('Selected date: $year-$monthName-$day \n $dates');
},
)
-
initialDate: This receive a DateTime that you want to be the initial date.
-
lastDate: This receive a DateTime that you want to be the last date.
-
eventDates: This receive a List of events dates with the parameters date, description and title.
-
annualEvents: This receive a Boolean to say if the event list is annual or not.
-
locale: This receive a String that will be locale for the intl get the exact translantion of thes month and weekdays.
-
calendarType: This parementer can receive CalendarType.civilCalendar or CalendarType.notCivilCalendar. If you select civiCalendart, the week will start on Monday, but if you select notCivilCalendar, then will start with on a Sunday.
-
weekdayType: This paramenter can receive WeekDayType.short, WeekDayType.medium and WeekDayType.long. If you select short, then the weekday will show only the first letter, if you select medium, then the weekday will show only the 3 letters and if you select long, then the weekday will show the full name.
-
controller: This receive the controller that you initialized before.
-
onBackwardOrForward: This receive a function so it may retrieve the month and year when gobackwar or forward on the month or year.
-
onDayAddedOrRemoved: This receive a function so it may retrieve the day, month, monthName, year or list of date when a day is added or removed.
-
This is Smart Calendar with the extra month calendar showing
-
This is Smart Calendar with calendartype as notCivilCalendar
Install the dependencies.
flutter pub get add smart_calendart
The library was completely made with dart and is still under development, hope this library can help you the same way is helping me. Here is the link to Github - Project example.