繁体   English   中英

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

[英]Dart: The type of function literal can't be inferred because the literal has a block as its body

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

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

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

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

void替换var将消除该警告。 这个问题和你的类似。

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM