首页 > 解决方案 > Flutter中如何将多个参数传递给调用SfCalender的onTap的函数?

问题描述

我正在使用 SfCalender 并希望将一个参数传递给 onTap 的回调

                 SfCalendar(
                  dataSource: _getDataSource(snapshot.data.data),
                  view: CalendarView.month,
                  showNavigationArrow: true,
                  monthViewSettings: MonthViewSettings(
                    showAgenda: true,
                    agendaStyle: AgendaStyle(
                      backgroundColor: Colors.transparent,
                      appointmentTextStyle: TextStyle(
                          color: Colors.white, fontSize: 13, fontStyle: FontStyle.italic),
                      dateTextStyle: TextStyle(
                          color: primaryColor, fontSize: 13, fontStyle: FontStyle.italic),
                    ),
                  ),
                  controller: _calendarController,
                  onTap: _openForm(array),
                )


         _openForm(CalendarTapDetails details) {
             //code

           } 

目前,如果我不向 _openForm 传递任何参数,CalenderDetails 详细信息具有值,但我想将一个数组与 CalenderDetails 详细信息一起传递。我怎样才能做到这一点?

标签: flutterdartflutter-layoutflutter-web

解决方案


我不知道 SfCalendar 库(它是封闭源代码),但我认为您正在尝试这样做:

onTap: (details) => _openForm(details, array);

// ...
_openForm(CalendarTapDetails details, List myArray) { 
// code
}

推荐阅读