unawaited_futures

Group: style

Maturity: stable

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

Since info is static, may be stale
pedantic

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 package:pedantic. The // ignore and // ignore_for_file comments also work.

GOOD:

Future doSomething() => ...;

void main() async {
  await doSomething();

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

BAD:

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