unawaited function

  1. @Since("2.15")
void unawaited(
  1. Future<void>? future
)

Explicitly ignores a future.

Not all futures need to be awaited. The Dart linter has an optional "unawaited futures" lint which enforces that potential futures (expressions with a static type of Future or Future?) in asynchronous functions are handled somehow. If a particular future value doesn't need to be awaited, you can call unawaited(...) with it, which will avoid the lint, simply because the expression no longer has type Future. Using unawaited has no other effect. You should use unawaited to convey the intention of deliberately not waiting for the future.

If the future completes with an error, it was likely a mistake to not await it. That error will still occur and will be considered unhandled unless the same future is awaited (or otherwise handled) elsewhere too. Because of that, unawaited should only be used for futures that are expected to complete with a value. You can use FutureExtensions.ignore if you also don't want to know about errors from this future.

Implementation

@Since("2.15")
void unawaited(Future<void>? future) {}