Errors caught by Flutter

For example, to make your application quit immediately any time an
error is caught by Flutter in release mode, you could use the
following handler:

Note:
  The top-level kReleaseMode constant indicates
  whether the app was compiled in release mode.

This handler can also be used to report errors to a logging service.
For more details, see our cookbook chapter for
reporting errors to a service.

Define a custom error widget for build phase errors

To define a customized error widget that displays whenever
the builder fails to build a widget, use MaterialApp.builder.

Errors not caught by Flutter

Consider an onPressed callback that invokes an asynchronous function,
such as MethodChannel.invokeMethod (or pretty much any plugin).
For example:

If invokeMethod throws an error, it won’t be forwarded to FlutterError.onError.
Instead, it’s forwarded to the PlatformDispatcher.