set static method

bool set({
  1. FlutterExceptionHandler? handler,
  2. ErrorWidgetBuilder? screen,
  3. ReportErrorHandler? report,
})

Set a handler and the report

Implementation

static bool set({
  FlutterExceptionHandler? handler,
  ErrorWidgetBuilder? screen,
  ReportErrorHandler? report,
}) {
  // Once you're not allowed to reset the handlers, it can't be reversed.
  if (!_allowNewHandlers) {
    return false;
  }

  // Are you allowed to reset a handler?
  // Only if an item was passed to reset.
  var reset = false;

  if (handler != null) {
    // The default is to dump the error to the console. You can do more.
    _onError = handler;
    reset = true;
  }

  if (report != null) {
    _errorReport = report;
    reset = true;
  }

  if (screen != null) {
    // Change the widget presented when another widget fails to build.
    ErrorWidget.builder = screen;
    reset = true;
  }
  // Something was set;
  return reset;
}