onError property

ErrorCallback? get onError

A callback that is invoked when an unhandled error occurs in the root isolate.

This callback must return true if it has handled the error. Otherwise, it must return false and a fallback mechanism such as printing to stderr will be used, as configured by the specific platform embedding via Settings::unhandled_exception_callback.

The VM or the process may exit or become unresponsive after calling this callback. The callback will not be called for exceptions that cause the VM or process to terminate or become unresponsive before the callback can be invoked.

This callback is not directly invoked by errors in child isolates of the root isolate. Programs that create new isolates must listen for errors on those isolates and forward the errors to the root isolate.

Implementation

ErrorCallback? get onError => _onError;
set onError (ErrorCallback? callback)

Implementation

set onError(ErrorCallback? callback) {
  _onError = callback;
  _onErrorZone = Zone.current;
}