install method

void install()

Installs the handler. Call once, before runApp.

Chains rather than replaces: FlutterError.presentError is what puts the error on the console and in the red box, and swallowing that to collect it would trade a visible failure for a queryable one.

Implementation

void install() {
  var previous = FlutterError.onError;
  FlutterError.onError = (details) {
    report(details);
    (previous ?? FlutterError.presentError)(details);
  };
}