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

Man*_*nnu 5 dart flutter

我正在使用 flutter 开发一个应用程序。

在下面的代码中我收到此警告。

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

var onSelectSunriseNotification = () {
  print('Sunrise Notification clicked');
};
Run Code Online (Sandbox Code Playgroud)

Tir*_*tel 4

替换varvoid将删除该警告。这个问题和你的很相似。

void onSelectSunriseNotification = () {
    print('Sunrise Notification clicked');
};
Run Code Online (Sandbox Code Playgroud)