6 dart
我只是在玩 Dart 期货,但遇到了一个错误:
未捕获的错误:NoSuchMethodError:找不到方法:'call$2' on null
然后我发现函数“结果”是原因。但是,如果我为该函数使用另一个名称,则一切正常。
Future<String> result() async {
var res = await process();
return 'Your order is: $res';
}
Future<String> process() {
return Future.delayed(Duration(seconds: 2), () => 'Water');
}
void main() async {
print(await result());
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以澄清这一点吗?
| 归档时间: |
|
| 查看次数: |
152 次 |
| 最近记录: |