错误:无法将参数类型“Null Function(DateTime, List<dynamic>)”分配给参数

Ham*_*hir 8 dart flutter

我面临同样的问题

     Error: 
        The argument type 'Null Function(DateTime, List<dynamic>)' can't be assigned 
        to the parameter type 'void Function(DateTime, List<dynamic>, List<dynamic>)'.
        - 'DateTime' is from 'dart:core'. - 'List' is from 'dart:core'. 
        onDaySelected: (day, events) {
Run Code Online (Sandbox Code Playgroud)

小智 10

That is one way how to avoid the error

onDaySelected: (date, event, _) {
    print(date.toIso8601String());
},
Run Code Online (Sandbox Code Playgroud)


Sps*_*mta 5

是的,我也遇到了同样的问题,它刚刚通过将“ _ ”放在第三个参数中解决了

onDaySelected: (date, events, _) {
        _onDaySelected(date, events);
        _animationController.forward(from: 0.0);
      },
Run Code Online (Sandbox Code Playgroud)


小智 4

我设法通过传递 _ 作为第三个参数来解决这个问题。