Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart:函数文本can的类型';无法推断,因为文字有一个块作为其主体_Dart_Flutter - Fatal编程技术网

Dart:函数文本can的类型';无法推断,因为文字有一个块作为其主体

Dart:函数文本can的类型';无法推断,因为文字有一个块作为其主体,dart,flutter,Dart,Flutter,我正在开发一个应用程序使用颤振 在下面的代码中,我得到了这个警告 无法推断函数文字的类型,因为文字有一个块作为其主体 将var替换为void将删除该警告。和你的相似 void onSelectSunriseNotification = () { print('Sunrise Notification clicked'); }; 在另一个函数中使用此选项也会删除警告: void main(){ var onSelectSunriseNotification=(){ 打印(“单击日出通知”

我正在开发一个应用程序使用颤振

在下面的代码中,我得到了这个警告

无法推断函数文字的类型,因为文字有一个块作为其主体


var
替换为
void
将删除该警告。和你的相似

void onSelectSunriseNotification = () {
    print('Sunrise Notification clicked');
};

在另一个函数中使用此选项也会删除警告:

void main(){
var onSelectSunriseNotification=(){
打印(“单击日出通知”);
};
}
void onSelectSunriseNotification = () {
    print('Sunrise Notification clicked');
};