diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 506a14abb2..79d9156c1c 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -2937,7 +2937,7 @@ Iterable debugTransformDebugCreator(Iterable p if (!foundStackTrace && node is DiagnosticsStackTrace) foundStackTrace = true; if (_isDebugCreator(node)) { - yield* _parseDiagnosticsNode(node, errorSummary)!; + yield* _parseDiagnosticsNode(node, errorSummary); } else { if (foundStackTrace) { pending.add(node); @@ -2952,15 +2952,27 @@ Iterable debugTransformDebugCreator(Iterable p /// Transform the input [DiagnosticsNode]. /// /// Return null if input [DiagnosticsNode] is not applicable. -Iterable? _parseDiagnosticsNode( +Iterable _parseDiagnosticsNode( DiagnosticsNode node, ErrorSummary? errorSummary, -) { - if (!_isDebugCreator(node)) - return null; - final DebugCreator debugCreator = node.value! as DebugCreator; - final Element element = debugCreator.element; - return _describeRelevantUserCode(element, errorSummary); +) sync* { + assert(_isDebugCreator(node)); + try { + final DebugCreator debugCreator = node.value! as DebugCreator; + final Element element = debugCreator.element; + yield* _describeRelevantUserCode(element, errorSummary); + } catch (error, stack) { + scheduleMicrotask(() { + FlutterError.reportError(FlutterErrorDetails( + exception: error, + stack: stack, + library: 'widget inspector', + informationCollector: () sync* { + yield DiagnosticsNode.message('This exception was caught while trying to describe the user-relevant code of another error.'); + } + )); + }); + } } Iterable _describeRelevantUserCode(