set static method
bool
set({
- FlutterExceptionHandler? handler,
- ErrorWidgetBuilder? screen,
- ReportErrorHandler? report,
- bool? allowNewErrorHandlers,
- bool? presentError,
- ParagraphStyle? paragraphStyle,
- TextStyle? textStyle,
- EdgeInsets? padding,
- double? minimumWidth,
- Color? backgroundColor,
Set a handler and the report
Implementation
static bool set({
FlutterExceptionHandler? handler,
ErrorWidgetBuilder? screen,
ReportErrorHandler? report,
bool? allowNewErrorHandlers,
bool? presentError,
i.ParagraphStyle? paragraphStyle,
i.TextStyle? textStyle,
EdgeInsets? padding,
double? minimumWidth,
Color? backgroundColor,
}) {
// Any subsequent assignments are not permitted.
_presentError ??= presentError;
_paragraphStyle ??= paragraphStyle;
_textStyle ??= textStyle;
_padding ??= padding;
_minimumWidth ??= minimumWidth;
_backgroundColor ??= backgroundColor;
// Once you're not allowed to set the handlers, they can't be changed.
if (_givenErrorHandler && !AppErrorHandler.allowNewErrorHandlers) {
return false;
}
// Are you allowed to reset a handler?
// Only if an item was passed to reset.
var reset = false;
if (handler != null) {
_errorHandler = handler;
reset = true;
}
if (report != null) {
_errorReport = report;
reset = true;
}
if (screen != null) {
// Record the current 'Error Widget'
_oldBuilder ??= ErrorWidget.builder;
// if not already assigned
if (ErrorWidget.builder != screen) {
ErrorWidget.builder = screen;
}
reset = true;
}
// Flag when something was assigned
if (!_givenErrorHandler && reset) {
// Set only once
_givenErrorHandler = true;
}
/// Allow for a new Error handler in the future
if (AppErrorHandler.allowNewErrorHandlers &&
!(allowNewErrorHandlers ?? true)) {
// Once set to false, it's unchangeable
AppErrorHandler.allowNewErrorHandlers = false;
}
// Something was set;
return reset;
}