unawaited_futures

Group: style

Maturity: stable

Dart SDK: >= 2.0.0 • (Linter v0.1.19)

Since info is static, may be stale
has-fix

View all Lint Rules

Using the Linter

DO await functions that return a Future inside of an async function body.

It's easy to forget await in async methods as naming conventions usually don't tell us if a method is sync or async (except for some in dart:io).

When you really do want to start a fire-and-forget Future, the recommended way is to use unawaited from dart:async. The // ignore and // ignore_for_file comments also work.

BAD:

void main() async {
  doSomething(); // Likely a bug.
}

GOOD:

Future doSomething() => ...;

void main() async {
  await doSomething();

  unawaited(doSomething()); // Explicitly-ignored fire-and-forget.
}