install method
void
install()
Install global handlers so all uncaught errors are reported, and drain any native crashes persisted from a previous run.
Implementation
void install() {
// 1) Flutter framework errors (build/layout/paint, gesture callbacks, …).
final prevFlutter = FlutterError.onError;
FlutterError.onError = (details) {
// Our reporting must never disrupt Flutter's own error handling.
try {
capture(details.exception, details.stack, {'handled': false});
} catch (_) {/* never let the reporter break error handling */}
prevFlutter?.call(details);
};
// 2) Uncaught async / platform-dispatcher errors on this isolate. Returning
// false lets the default handler still print to the console.
final prevPlatform = PlatformDispatcher.instance.onError;
PlatformDispatcher.instance.onError = (error, stack) {
try {
capture(error, stack, {'handled': false});
} catch (_) {/* never let the reporter break error handling */}
return prevPlatform?.call(error, stack) ?? false;
};
// 3) Native crashes: ask the native SDK to install its uncaught-exception /
// signal handlers, and forward any crash it persisted last run.
NexusPlatform.instance.configureCrashReporting(true);
_drainNativeCrashes();
}