errorDisplayWidget static method
Widget
errorDisplayWidget(
- FlutterErrorDetails details, {
- ParagraphStyle? paragraphStyle,
- TextStyle? textStyle,
- EdgeInsets? padding,
- double? minimumWidth,
- Color? backgroundColor,
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 errorDisplayWidget(
FlutterErrorDetails details, {
i.ParagraphStyle? paragraphStyle,
i.TextStyle? textStyle,
EdgeInsets? padding,
double? minimumWidth,
Color? backgroundColor,
}) {
String message;
try {
message = 'ERROR\n\n${details.exception}\n\n';
final stackTrace = details.stack.toString().split('\n');
final length = stackTrace.length > 5 ? 5 : stackTrace.length;
final buffer = StringBuffer()..write(message);
for (var i = 0; i < length; i++) {
buffer.write('${stackTrace[i]}\n');
}
message = buffer.toString();
} catch (e) {
message = 'Error';
}
return _ErrorRenderObjectWidget(
message: message,
error: details.exception,
paragraphStyle: paragraphStyle,
textStyle: textStyle,
padding: padding,
minimumWidth: minimumWidth,
backgroundColor: backgroundColor,
);
}