displayErrorWidget static method
Widget
displayErrorWidget(
- FlutterErrorDetails details, {
- Key? key,
- String? header,
- ParagraphStyle? paragraphStyle,
- TextStyle? textStyle,
- EdgeInsets? padding,
- double? minimumWidth,
- Color? backgroundColor,
- bool? stackTrace,
This function is intentionally doing things using the low-level primitives to avoid depending on any subsystems that may have ended up in an unstable state -- after all, this class is mainly used when things have gone wrong.
Implementation
static Widget displayErrorWidget(
FlutterErrorDetails details, {
Key? key,
String? header,
i.ParagraphStyle? paragraphStyle,
i.TextStyle? textStyle,
EdgeInsets? padding,
double? minimumWidth,
Color? backgroundColor,
bool? stackTrace,
}) {
//
String? message;
//
try {
//
message = '\n\n${details.exception}\n\n';
if (details.stack != null && (stackTrace ?? true)) {
//
final stack = details.stack.toString().split('\n');
final length = stack.length > 5 ? 5 : stack.length;
final buffer = StringBuffer()..write(message);
for (var i = 0; i < length; i++) {
buffer.write('${stack[i]}\n');
}
message = buffer.toString();
}
} catch (e) {
message = null;
}
//
return _ErrorRenderObjectWidget(
key: key,
header: header,
message: message,
error: details.exception,
paragraphStyle: paragraphStyle,
textStyle: textStyle,
padding: padding,
minimumWidth: minimumWidth,
backgroundColor: backgroundColor ?? const Color(0xFFFFFFFF),
);
}