- [Add event listening to controller](#%e7%bb%99controller%e6%b7%bb%e5%8a%a0%e4%ba%8b%e4%bb%b6%e7%9b%91%e5%90%ac)
- [Using controller to control the switching of calendar and support the configuration of animation](#%e5%88%a9%e7%94%a8controller%e6%9d%a5%e6%8e%a7%e5%88%b6%e6%97%a5%e5%8e%86%e7%9a%84%e5%88%87%e6%8d%a2%e6%94%af%e6%8c%81%e9%85%8d%e7%bd%ae%e5%8a%a8%e7%94%bb)
- [Using controller to get the status and data of current calendar](#%e5%88%a9%e7%94%a8controller%e6%9d%a5%e8%8e%b7%e5%8f%96%e5%bd%93%e5%89%8d%e6%97%a5%e5%8e%86%e7%9a%84%e7%8a%b6%e6%80%81%e5%92%8c%e6%95%b0%e6%8d%ae)
- [How to customize UI](#%e5%a6%82%e4%bd%95%e8%87%aa%e5%ae%9a%e4%b9%89ui)
- [Customize extra data extradata according to the actual scenario](#%e6%a0%b9%e6%8d%ae%e5%ae%9e%e9%99%85%e5%9c%ba%e6%99%af%e8%87%aa%e5%ae%9a%e4%b9%89%e9%a2%9d%e5%a4%96%e7%9a%84%e6%95%b0%e6%8d%aeextradata)
- [Calendar with progress bar style](#%e5%ae%9e%e7%8e%b0%e8%bf%9b%e5%ba%a6%e6%9d%a1%e6%a0%b7%e5%bc%8f%e7%9a%84%e6%97%a5%e5%8e%86)
- [Implement custom calendars for various tags](#%e5%ae%9e%e7%8e%b0%e8%87%aa%e5%ae%9a%e4%b9%89%e5%90%84%e7%a7%8d%e6%a0%87%e8%ae%b0%e7%9a%84%e6%97%a5%e5%8e%86)
- [Modify customized data manually](#%e6%89%8b%e5%8a%a8%e4%bf%ae%e6%94%b9%e8%87%aa%e5%ae%9a%e4%b9%89%e7%9a%84%e6%95%b0%e6%8d%ae)
| selectMode | Selection mode, indicating single selection or multiple selection | default is single select<br>static const int MODE_SINGLE_SELECT = 1;<br>static const int MODE_MULTI_SELECT = 2; |
| showMode | Display mode | 默认是只展示月视图<br>static const int MODE_SHOW_ONLY_MONTH=1;//仅支持月视图<br>static const int MODE_SHOW_ONLY_WEEK=2;//仅支持星期视图<br>static const int MODE_SHOW_WEEK_AND_MONTH=3;//支持两种视图,先显示周视图<br>static const int MODE_SHOW_MONTH_AND_WEEK=4;//支持两种视图,先显示月视图 |
| minYear | Minimum year for calendar display | 1971 |
| maxYear | Maximum year displayed in calendar | 2055 |
| minYearMonth | The month of the smallest year displayed by the calendar | 1 |
| maxYearMonth | The month of the largest year displayed by the calendar | 12 |
| nowYear | Current year displayed by calendar | -1 |
| nowMonth | Current month displayed by calendar | -1 |
| minSelectYear | Minimum year that can be selected | 1971 |
| minSelectMonth | Month of the smallest year that can be selected | 1 |
| minSelectDay | The day of the smallest month you can choose | 1 |
| maxSelectYear | Maximum year that can be selected | 2055 |
| maxSelectMonth | Month of the largest year you can choose | 12 |
| maxSelectDay | The day of the largest month you can choose | 30,注意:不能超过对应月份的总天数 |
| selectedDateList | Selected date for multiple selections | 默认为空Set, Set<DateModel> selectedDateList = new Set() |
| selectDateModel | Current selection, for radio selection | 默认为空 |
| maxMultiSelectCount | Multiple choice, how many at most | hhh |
| extraDataMap | Customize additional data | 默认为空Map,Map<DateTime,Object> extraDataMap = new Map() |
| Future<bool> previousPage() | Sliding to the previous page will automatically slide to the previous month or week according to the current deployment status. If it is already on the first page and there is no previous page, it will return false, otherwise it will return true |
| Future<bool> nextPage() | Sliding to the next page will automatically move to the next month or week according to the current deployment status. If it is already on the last page and there is no next page, it will return false, otherwise it will return true |
| void moveToCalendar(int year, int month, int day, {bool needAnimation = false,Duration duration = const Duration(milliseconds: 500),Curve curve = Curves.ease}) | To specified date |
| void moveToNextYear() | Switch to next year |
| void moveToPreviousYear() | Switch to previous year |
| void moveToNextMonth() | Switch to the next month |
| void moveToPreviousMonth() | Switch to previous month |
| void toggleExpandStatus() | Toggle deployment state |
| void changeExtraData(Map<DateModel,Object> newMap) | Modify custom extra data and refresh calendar |
#### Using controller to get the status and data of current calendar
| DateTime getCurrentMonth() | Get the current month |
| Set<DateModel> getMultiSelectCalendar() | Get selected date,multiple choices |
| DateModel getSingleSelectCalendar() | Get selected date,single choiice |
### How to customize UI
Including custom weekbar and custom calendar item. Defaultxxwidget is used by default.
As long as we inherit the corresponding base class and implement the corresponding methods, then we only need to implement the corresponding builder methods when configuring the controller.
There are two methods, one is to create by combining widgets, and the other is to draw items by using canvas. Finally, you only need to configure in the construction parameters of the calendarcontroller。
* Create by combining widgets: inherit basecombinedaywidget, rewrite getnormalwidget (datemodel datemodel) and getselectedwidget (datemodel datemodel), and return the corresponding widget.
```
class DefaultCombineDayWidget extends BaseCombineDayWidget {
//When creating the calendarcontroller object, assign the extradatamap
new CalendarController(
extraDataMap: customExtraData)
//When drawing daywidget, you can get the desired data directly from the extradata object of datemodel
String data = dateModel.extraData;
```
#### Modify customized data manually
When the customized data changes, you can use the controller's change extradata (map <datemodel,Object> NewMap) method,The calendar will refresh automatically and draw based on the new additional data
The entity class datemodel of the date used by the calendar has the following properties. You can draw the corresponding UI after judging according to the corresponding properties when you customize the daywidget.
| DateTime getDateTime() | Convert datemodel to datetime |
| DateModel fromDateTime(DateTime dateTime) | Create corresponding model according to datetime, and initialize information such as lunar calendar and traditional festivals |
| bool operator ==(Object other) | Override the = = method to determine whether two datemodels are the same day |