errorDisplayWidget static method
This class 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) {
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);
}