avoid_future_ignore
v1.0.0 Warning Async Safety
This rule flags Future.ignore() when no adjacent comment explains why both
the result and any asynchronous error are intentionally irrelevant. It only
matches Dart’s FutureExtensions.ignore, so an unrelated class with its own
ignore() method is left alone.
The rule is part of the recommended preset.
Why use this rule
Section titled “Why use this rule”unawaited(future) documents fire-and-forget execution while leaving an
unexpected error visible to the current zone. future.ignore() goes further:
it installs an error handler that deliberately consumes the error. That is
occasionally correct, but it should be a reviewed decision rather than a
convenient way to silence unawaited_futures.
An immediately preceding line or block comment exempts the call. This keeps best-effort cleanup and obsolete requests expressible while making the reason visible beside the suppression.
See also: Dart Future.ignore(), DCM avoid-future-ignore, unawaited_futures
void saveInBackground(Future<void> save) { save.ignore(); // failures disappear}Keep unexpected errors observable:
import 'dart:async';
void saveInBackground(Future<void> save) { unawaited(save);}When suppressing errors is genuinely part of the contract, document it:
void discardObsoleteRequest(Future<void> request) { // The response is obsolete, including any failure it produces. request.ignore();}Turning this rule off
Section titled “Turning this rule off”To disable this rule:
rules: avoid_future_ignore: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”prefer_correct_future_return_type— Expose async results as non-nullable Future values.avoid_nested_futures— Don’t declare Future<Future<T>>.avoid_passing_async_when_sync_expected— Don’t pass an async closure where a void-returning function is expected.avoid_redundant_async— Flag an async function that never awaits.