The return type 'String' isn't a 'Future<void>', as required by the closure's context.
时间: 2023-11-27 16:02:28 浏览: 123
闭包:权威指南(Closure: The Definitive Guide)
4星 · 用户满意度95%
This error occurs when a function or closure is expected to return a `Future<void>` but instead returns a `String`.
To fix this error, you need to make sure that the function or closure returns a `Future<void>` instead of a `String`. You can do this by replacing the `return` statement with `return Future.value(null);` or simply `return null;`.
For example:
```dart
Future<void> myFunction() async {
// do something
return null;
}
```
Or
```dart
Future<void> myFunction() {
// do something
return Future.value(null);
}
```
阅读全文