reportError method Null safety

void reportError(
  1. FlutterErrorDetails details

Calls onError with the given details, unless it is null.

When calling this from a catch block consider annotating the method containing the catch block with @pragma('vm:notify-debugger-on-exception') to allow an attached debugger to treat the exception as unhandled. This means instead of executing the catch block, the debugger can break at the original source location from which the exception was thrown.
void doSomething() {
  try {
  } catch (exception, stack) {
      exception: exception,
      stack: stack,
      library: 'example library',
      context: ErrorDescription('while doing something'),


static void reportError(FlutterErrorDetails details) {
  assert(details != null);
  assert(details.exception != null);