Closed ThinkDigitalSoftware closed 6 months ago
Good catch. Thanks for the report!
My pleasure!
/cc @a14n
I don't see this as a bug.
In the first snippet there's no return
and async/await
are needed.
I rather think the refactoring should be changed to have convertions (block/expression) as follow:
Future f() => aFuture;
Future f() async {
return await aFuture;
}
Future<void> v() => aVoidFuture;
Future<void> v() async {
await aVoidFuture;
}
In my case, the callback definition isn't async, but it supports it. Just like onPressed() callbacks. so I can't define that it's a Future
typedef OnInitialBuildCallback<ViewModel> = void Function(ViewModel viewModel)
I agree with @a14n; the code in question doesn't have a return statement, so the lint rule does not apply.
Describe the issue Linter shows unnecessary_await_in_return if in an expression body, but not when the statement is a block body.
To Reproduce
No issue here, but when converted to an expression body, it shows a warning.
Expected behavior if it's a simple refactor, then it shouldn't change the correctness of the statement. We should either not offer the refactor, or not show a warning here. I know the fat arrow is short for return, but that's not always desirable nor correct, especially when using void functions.