onAddError method Null safety

  1. @override
void onAddError(
  1. Object error,
  2. [StackTrace? stackTrace]
)
override

An extension point for sub-classes. Perform any side-effect / state management you need to here, rather than overriding the add method directly.

Implementation

@override
void onAddError(Object error, [StackTrace? stackTrace]) {
  if (_queue.length == _maxSize) {
    _queue.removeFirst();
  }

  _queue.add(_Event.error(ErrorAndStackTrace(error, stackTrace)));
}