async_ return_ with_ no_ await
Learn about the async_return_with_no_await linter rule.
Return with no await.
Details
#
DO use await when returning a Future from an async
function.
BAD:
Future<String> futureString(Future<String> value) async {
return value;
}
Future<int> futureInt(Future<int> value) async => value;
GOOD:
Future<String> futureString(Future<String> value) async {
return await value;
}
Future<int> futureInt(Future<int> value) => value;
Enable
#
To enable the async_return_with_no_await rule, add async_return_with_no_await
under
linter > rules in your analysis_options.yaml
file:
linter:
rules:
- async_return_with_no_await
If you're instead using the YAML map syntax to configure linter rules,
add async_return_with_no_await: true under linter > rules:
linter:
rules:
async_return_with_no_await: true
Unless stated otherwise, the documentation on this site reflects Dart 3.12.2. Report an issue.