Skip to main content

avoid-missing-completer-stack-trace

added in: 1.15.0
preset: recommended

Warns when Completer.completeError is called without providing a stack trace.

By default, completeError gets an empty stack trace. Consider passing StackTrace.current or Error(...).stackTrace to the invocation.

Example

❌ Bad:

import 'dart:async';

void fn() {
final completer = Completer();
completer.completeError('foo'); // LINT

Completer().completeError('foo'); // LINT
}

✅ Good:

import 'dart:async';

void fn() {
final completer = Completer();
completer.completeError('foo', StackTrace.current);

Completer().completeError('foo', Error(...).stackTrace);
}