flutter - Flutter 表日历:CalendarController 问题
问题描述
所以根据表日历版本的更新日志。3.0.0,CalendarController
被删除。我的代码上有它,现在它显示为错误Undefined class 'CalendarController'。现在,我想知道该怎么做,因为我在任何地方都找不到答案。另外,有人可以向我解释一下最初的用途是CalendarController
什么?
任何帮助将不胜感激,谢谢!
解决方案
就像变更日志所说的那样,CalendarController 在较新的版本中被删除。它用于突出显示的(当前选择的)日功能。
您可以通过将这些属性添加到TableCalender()来手动配置所选日期:
selectedDayPredicate: (day) {
// Use `selectedDayPredicate` to determine which day is currently selected.
// If this returns true, then `day` will be marked as selected.
// Using `isSameDay` is recommended to disregard
// the time-part of compared DateTime objects.
return isSameDay(_selectedDay, day);
},
onDaySelected: (selectedDay, focusedDay) {
if (!isSameDay(_selectedDay, selectedDay)) {
// Call `setState()` when updating the selected day
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
}
},
onFormatChanged: (format) {
if (_calendarFormat != format) {
// Call `setState()` when updating calendar format
setState(() {
_calendarFormat = format;
});
}
},
onPageChanged: (focusedDay) {
// No need to call `setState()` here
_focusedDay = focusedDay;
},
还要确保定义firstDay:、lastDay: 和 focusDay:,因为它是 TableCalendar() 函数所必需的,并且还要设置 calendarFormat。
参考官方 table_calendar 示例:https ://github.com/aleksanderwozniak/table_calendar/blob/master/example/lib/pages/basics_example.dart
推荐阅读
- browser - Javascript如何使历史回退强制刷新?
- node.js - 尝试在 node.js 中使用 axios 复制 curl -c post/get
- unity3d - 一个一个地显示 10 个单独的网格,并具有循环行为以为空的游戏对象创建“动画”?
- javascript - 当页面在 IE11 中冻结时,如何防止触发 OnBlur 事件
- python - 如何在python中的csv文件的起始位置添加列?
- python - Django模型视图集内置删除方法不起作用
- objective-c - WKWebView:如何在 objc 中打开另一个 WKWebView
- python - pyparsing 以与输入文本相同的顺序对匹配的字符串和不匹配的字符串进行分组
- javascript - 将两个节点应用服务器连接到单个 mongo db 数据库
- r - r:在数据框中将过滤器与 n_distinct 组合