semanticNodes method

Iterable<DebugCaptureSemanticNode> semanticNodes({
  1. String? role,
  2. String? label,
  3. Object? value,
  4. bool? focused,
  5. bool? selected,
  6. String? action,
  7. Map<String, Object?> stateContains = const <String, Object?>{},
})

Implementation

Iterable<DebugCaptureSemanticNode> semanticNodes({
  String? role,
  String? label,
  Object? value,
  bool? focused,
  bool? selected,
  String? action,
  Map<String, Object?> stateContains = const <String, Object?>{},
}) sync* {
  final semantics = _jsonMap(_json['semantics']);
  final root = _jsonMap(semantics['root']);
  if (root.isEmpty) return;

  final stack = <Map<String, Object?>>[root];
  while (stack.isNotEmpty) {
    final node = DebugCaptureSemanticNode._(stack.removeLast());
    if (node._matches(
      role: role,
      label: label,
      value: value,
      focused: focused,
      selected: selected,
      action: action,
      stateContains: stateContains,
    )) {
      yield node;
    }
    final children = node._children;
    for (var i = children.length - 1; i >= 0; i--) {
      stack.add(children[i]);
    }
  }
}