Flutter 颤振日历旋转木马根据月份显示事件

Flutter 颤振日历旋转木马根据月份显示事件,flutter,calendar,Flutter,Calendar,我正在尝试使用Flatter日历旋转木马构建一个日历应用程序。我需要做的是,当用户浏览月份时,我想显示分配给月份的事件 checkCurrentMonth() { selectedMonth = DateTime.parse(_targetDateTime.toString()).month.toInt(); selectedYear = DateTime.parse(_targetDateTime.toString()).year.toInt(); _markedDa

我正在尝试使用Flatter日历旋转木马构建一个日历应用程序。我需要做的是,当用户浏览月份时,我想显示分配给月份的事件

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
类“List”没有实例getter“getTitle”。
接收者:“\u GrowtableList”的实例(长度:1)
已尝试呼叫:getTitle
这是我的地图

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,
          ),
        ),
      ],
    },
  );
EventList\u markedDateMap=新事件列表(
活动:{
新日期时间(2020年12月29日):[
新事件(
日期:新日期时间(2020年12月29日),
标题:“波亚日”,
图标:_poyaeventIcon(DateTime(2020,12,29).day.toString()),
dot:容器(
边缘:边缘组。对称(水平:1.0),
颜色:颜色,红色,
身高:5.0,
宽度:5.0,
),
),
],
新日期时间(2021年1月14日):[
新事件(
日期:新日期时间(2021年1月14日),
标题:“泰米尔泰邦日”,
图标:_otheralleventIcon(DateTime(2021,01,14).day.toString()),
dot:容器(
边缘:边缘组。对称(水平:1.0),
颜色:颜色,红色,
身高:5.0,
宽度:5.0,
),
),
],
},
);

请帮我解决这个问题。

除了本机内置方法外,您不能调用
列表中的其他方法。实际上,您正在调用
事件列表中的
getTitle
方法。如果要查看列表中所有事件的标题,必须使用循环或获取特定索引。

for (var event in _selectedHolidays[0]) print(event.getTitle());

// or

print(_selectedHolidays[0].first.getTitle());

你的
\u MarkerDateMap
声明在哪里?嗨@dm\tr我编辑了我的问题检查我的答案