AppErrorHandler constructor
AppErrorHandler({
- FlutterExceptionHandler? handler,
- ErrorWidgetBuilder? screen,
- ReportErrorHandler? report,
- bool? allowNewHandlers,
Singleton Pattern with only one instance of this Error Handler. Optionally supply the Error handler, Builder, and Report routines.
Implementation
factory AppErrorHandler({
FlutterExceptionHandler? handler,
ErrorWidgetBuilder? screen,
ReportErrorHandler? report,
bool? allowNewHandlers,
}) {
//
_this ??= AppErrorHandler._();
/// Allows you to set an error handler more than once.
final reassigned = set(handler: handler, screen: screen, report: report);
// Allow for null. Simply allow new handles by default
allowNewHandlers ??= true;
// Once set to false, you can't assign different handlers anymore.
// However, it's set to false only if one of the handlers was reassigned.
if (!allowNewHandlers && reassigned) {
_allowNewHandlers = false;
}
return _this!;
}