ExceptionWatcher class

Hooks both FlutterError.onError and PlatformDispatcher.instance.onError to capture all unhandled exceptions in a Flutter app.

This matches the Flutter "Handling errors" canonical pattern:

  • FlutterError.onError covers synchronous framework + widget errors (null dereferences, assertion failures, layout overflows, etc.).
  • PlatformDispatcher.instance.onError covers asynchronous errors, errors from other isolates, and plugin-originated errors; paths that never reach FlutterError.onError.

Both hooks chain-preserve any previously-registered handler (Sentry, Bugsnag, etc.) so that downstream observability is never silently masked. The PlatformDispatcher.onError handler chain-preserves the previous handler's return value (_previousPlatformOnError?.call(...) ?? true). When a previously-registered handler returns false, this watcher also returns false, which propagates the error to the native platform crash handler. This is the Sentry-friendly contract: telescope captures the record AND lets the downstream library decide whether the error is fatal. When no previous handler exists, the default is true (handled) which matches the pre-iter-2 single-hook behavior.

On uninstall, both handlers are restored to exactly the values they held before install was called. Calling install while already installed is a no-op (idempotent).

Implemented types

Constructors

ExceptionWatcher()

Properties

hashCode int
The hash code for this object.
no setterinherited
name String
Human-readable watcher name.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

install() → void
Wire the watcher's listening hook (event subscription, override, etc.).
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
uninstall() → void
Tear down the hook (test isolation).
override

Operators

operator ==(Object other) bool
The equality operator.
inherited