Skip to content

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.

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();
}

To disable this rule:

many_lints.yaml
rules:
avoid_future_ignore: false

To keep the rule on but skip certain paths, use per-rule exclude.