debugTransformDebugCreator function Null safety

Iterable<DiagnosticsNode> debugTransformDebugCreator(
  1. Iterable<DiagnosticsNode> properties
)

Transformer to parse and gather information about DiagnosticsDebugCreator.

This function will be registered to FlutterErrorDetails.propertiesTransformers in WidgetsBinding.initInstances.

This is meant to be called only in debug mode. In other modes, it yields an empty list.

Implementation

Iterable<DiagnosticsNode> debugTransformDebugCreator(Iterable<DiagnosticsNode> properties) sync* {
  if (!kDebugMode) {
    return;
  }
  final List<DiagnosticsNode> pending = <DiagnosticsNode>[];
  ErrorSummary? errorSummary;
  for (final DiagnosticsNode node in properties) {
    if (node is ErrorSummary) {
      errorSummary = node;
      break;
    }
  }
  bool foundStackTrace = false;
  for (final DiagnosticsNode node in properties) {
    if (!foundStackTrace && node is DiagnosticsStackTrace)
      foundStackTrace = true;
    if (_isDebugCreator(node)) {
      yield* _parseDiagnosticsNode(node, errorSummary)!;
    } else {
      if (foundStackTrace) {
        pending.add(node);
      } else {
        yield node;
      }
    }
  }
  yield* pending;
}