Clean Calendar 是一個現代且可自定義的 Flutter 套件,專為輕鬆建立優雅簡潔的日曆而設計。它提供清晰的 API,可在 Android、iOS、Web、macOS、Windows 和 Linux 等多個平台建立互動式日曆檢視。支援日期、樣式與事件整合的自訂功能,非常適合需要直覺日期選擇或排程功能的應用程式。此套件強調簡單性與效能,同時保持高度彈性以供開發者使用。
適用情境
表單中的日期選擇
事件排程介面
每日計畫應用程式
基於日曆的資料篩選
使用者生日或預約追蹤
主要特色
高度可自訂的使用者介面
跨平台相容性
簡單的日期處理
支援事件標記
輕量級且快速渲染
適合對象
開發日曆功能的開發者
需要日期選擇器的應用
專注於乾淨的UI設計
Flutter 初學者探索組件
可自訂的日期介面
使用建議
有限的內建事件管理
需要手動實作複雜互動
無原生重複事件支援
基本用法之外的最小文件
依賴外部狀態管理來處理動態資料
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
Word from creator
Hello👋, Clean Calendar is in the early stages of development and can have many breaking changes. If you have any questions or suggestions, contact me via GitHub issues, email, discord, or any of the ways listed on my GitHub profile.
Yes, giving the package a 👍(Pub) or ⭐(Github) will encourage me to work on it more.
Package description
Get ready to enhance your Flutter app with this fantastic calendar package! With its simple yet elegant design, you can create a fully customized calendar that suits your needs. It provides a customizable month view and the ability to highlight dates with streaks. It is just the beginning, and we will add more features.
Customise date boundary behaviour and tap behaviour
CleanCalendar( )
CleanCalendar( // To allow date boundary to shrink. enableDenseViewForDates: true,
// To allow date tap splash to shrink. enableDenseSplashForDates: true, )
Note: This dense mode could lead to overflow if the available width to calendar is smaller than 280px so it is advised to disable them in smaller space than 280px.
// Enabling selecting single or multiple dates. Defaults to disable selection. dateSelectionMode: DatePickerSelectionMode.singleOrMultiple,
// Listening to selected dates. onSelectedDates: (List<DateTime> value) { // If selected date picked again then removing it from selected dates. if (selectedDates.contains(value.first)) { selectedDates.remove(value.first); } else { // If unselected date picked then adding it to selected dates. selectedDates.add(value.first); } // setState to update the calendar with new selected dates. setState(() {}); },
// Providing calendar the dates to select in ui. selectedDates: selectedDates,
Note:weekdaysSymbol defaults to Mo, Tu, We, Th, Fr, Sa, Su from monday to sunday and monthsSymbol defaults to January, February, March, April, May, June, July, August, September, October, November, December.
Accessing selected dates
To access selected dates use the onSelectedDates callback but keep in mind that this callback always provides a list of dates as shown below:
CleanCalendar(
...
onSelectedDates: (List<DateTime> selectedDates) {
// Called every time dates are selected or deselected.print(selectedDates);
},
)
Note: Even for single selection mode it provides a list with just one date and for multiple selection it provides a list with multiple dates.
Providing pre-selected dates
You can provide pre-selected dates by providing a list of dates to selectedDates as shown below:
Note: Even with selection mode set to single or disable it will still show the provided pre-selected dates as selected. And I think is the correct behavious as sometimes we might want to show selected dates while also preventing users from interacting with them.
Providing start and end dates
You can provide start and end dates for calendar view as shown below:
CleanCalendar(
...
// Setting start date of calendar.
startDateOfCalendar: DateTime(2022,6,5),
// Setting end date of calendar.
endDateOfCalendar: DateTime(2022,10,15),
)
Note:startDateOfCalendar defaults to DateTime.utc(0000, 1, 1) and endDateOfCalendar defaults to DateTime.utc(9999, 1, 1).
Providing initial month view for calendar
You can provide initial month view for calendar by providing date of that month as shown below:
Note:initialViewMonthDateTime defaults to current date and if current is not between startDateOfCalendar and endDateOfCalendar then defaults to start date..
Providing current date for calendar
You can provide current date for calendar as shown below:
CleanCalendar(
...
// Setting current date of calendar.
currentDateOfCalendar: DateTime(2022,9,5),
)
Note:currentDateOfCalendar defaults to DateTime.now().
Listening for calendar view week or month change
You can listen and get the current calendar view date on calendar view change. Useful in case you want to change your ui acording to the dates visible to user.
CleanCalendar(
...
onCalendarViewDate: (DateTime calendarViewDate) {
// Called every time view is changed like scrolled etc.print(calendarViewDate);
},
)
Note: For now onCalendarViewDate will only provide the view starting date. Later I may can add an option to get all dates of current view depending on users request. Also, onCalendarViewDate is called only on change of view like scroll, etc and will not be called on the creation of calendar as at thst time we already know the date.
Additional information
Support is surely planned for these:
Complete documentation.
Option to disable user interactions on whole view, past dates, and dates after-before end-start date. (🐇)
More customization and premade templates for calendar. (🐢)
More calendar view types. (🐢)
Date selection options such as range, and multiple range selections. (🐢)
A calendar option for choosing a view by year, month, or day. (🐢)
Support for dates to be displayed in events style. (🐢)
Dry mode, which optimizes performance for low-end devices by removing or substituting heavy animations and widgets. (🐢)
And, if I'm forgetting something crucial/important/necessary then please let me know.