ignore method Null safety

  1. @Since("2.14")
void ignore()

Completely ignores this future and its result.

Not all futures are important, not even if they contain errors, for example if a request was made, but the response is no longer needed. Simply ignoring a future can result in uncaught asynchronous errors. This method instead handles (and ignores) any values or errors coming from this future, making it safe to otherwise ignore the future.

Use ignore to signal that the result of the future is no longer important to the program, not even if it's an error. If you merely want to silence the "unawaited futures" lint, use the unawaited function instead. That will ensure that an unexpected error is still reported.


void ignore() {
  var self = this;
  if (self is _Future<T>) {
  } else {
    self.then<void>(_ignore, onError: _ignore);