【发布时间】:2021-04-01 05:12:29
【问题描述】:
我正在尝试使用颤振日历轮播构建日历应用程序。我需要做的是我想在用户滑动月份时显示分配给月份的事件。
checkCurrentMonth() {
selectedMonth = DateTime.parse(_targetDateTime.toString()).month.toInt();
selectedYear = DateTime.parse(_targetDateTime.toString()).year.toInt();
_markedDateMap.events.forEach((key, value) {
// print(_markedDateMap.events);
print(DateTime.parse(key.toString()).month.toInt());
if (selectedMonth == DateTime.parse(key.toString()).month.toInt() &&
selectedYear == DateTime.parse(key.toString()).year.toInt()) {
// print(_markedDateMap.events[key]);
_selectedHolidays.add(_markedDateMap.events[key]);
}
});
// for (var item in _selectedHolidays) {
// print("000000000000000 $item");
// gatheredEvents.add(GatherEvents.fromJson(item));
// }
print(_selectedHolidays[0].getTitle());
print(_markedDateMap.events.length);
}
我收到以下错误。
Class 'List<Event>' has no instance getter 'getTitle'.
Receiver: Instance(length:1) of '_GrowableList'
Tried calling: getTitle
这是我的 _markedDateMap
EventList<Event> _markedDateMap = new EventList<Event>(
events: {
new DateTime(2020, 12, 29): [
new Event(
date: new DateTime(2020, 12, 29),
title: 'Poya Day',
icon: _poyaeventIcon(DateTime(2020, 12, 29).day.toString()),
dot: Container(
margin: EdgeInsets.symmetric(horizontal: 1.0),
color: Colors.red,
height: 5.0,
width: 5.0,
),
),
],
new DateTime(2021, 01, 14): [
new Event(
date: new DateTime(2021, 01, 14),
title: 'Tamil Thai Pongal Day',
icon: _otheralleventIcon(DateTime(2021, 01, 14).day.toString()),
dot: Container(
margin: EdgeInsets.symmetric(horizontal: 1.0),
color: Colors.red,
height: 5.0,
width: 5.0,
),
),
],
},
);
请帮帮我。
【问题讨论】:
-
你的
_markerdDateMap声明在哪里? -
嗨@dm_tr 我编辑了我的问题
-
检查我的答案