summary property Null safety

DiagnosticsNode summary

Returns a short (one line) description of the problem that was detected.

If the exception contains an ErrorSummary that summary is used, otherwise the summary is inferred from the string representation of the exception.

In release mode, this always returns a DiagnosticsNode.message with a formatted version of the exception.


DiagnosticsNode get summary {
  String formatException() => exceptionAsString().split('\n')[0].trimLeft();
  if (kReleaseMode) {
    return DiagnosticsNode.message(formatException());
  final Diagnosticable? diagnosticable = _exceptionToDiagnosticable();
  DiagnosticsNode? summary;
  if (diagnosticable != null) {
    final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
    summary =<DiagnosticsNode?>().firstWhere((DiagnosticsNode? node) => node!.level == DiagnosticLevel.summary, orElse: () => null);
  return summary ?? ErrorSummary(formatException());