-
Notifications
You must be signed in to change notification settings - Fork 1.7k
discarded_futures
: Unwaited return for when Future is expected
#59331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report; this repo is for proposals to add existing lints to our recommended lint set. You might want to re-file this at the dart-lang/sdk repo? |
thanks. can you refer me to the page? |
discarded_futures
: Unwaited return for when Future is expected
The The description doesn't say that using See #59204. |
Hey @bsz0206, considering #59204, I've tested import 'dart:async';
Future<void> f() async {}
void g() {
unawaited(f());
} And got no lint, so I think this can be closed? If you have any other problems with the
|
No, the use case is different. The future functions returns something other than void: Future getMeAnString() async { FutureBuilder( then I would get: Asynchronous function invoked in a non-'async' function. Try converting the enclosing function to be 'async' and then 'await' the future. and I will have to add an //ignore : FutureBuilder( This literally means almost every FutureBuilder would need an extra ignore that is not nice.
|
Thanks for clarifying! Then this is the same as the other issues I mentioned. I'm working on a fix for this. |
@pq here is the CL: https://dart-review.googlesource.com/c/sdk/+/403901 Once you review it, can you also take a look at all of the issues mentioned to make sure you agree they are dupes? Thanks! |
I noticed that this should consider |
Unwaited does work only on void returns. We are forced to ignore, which is not nice:
FutureBuilder(
// ignore: discarded_futures
future: asyncCall(),
Unwaited does work only on void returns:
FutureBuilder(
future: unawaited(asyncCall()),,
The text was updated successfully, but these errors were encountered: