getDescendants method

List<PrettyNode> getDescendants([
  1. bool withMarkers = false
])

The children and their children.

Implementation

List<PrettyNode> getDescendants([bool withMarkers = false]) {
  final result = <PrettyNode>[];
  void loop(List<PrettyNode> nodes) {
    for (final node in nodes) {
      if (node is PrettyElement) {
        if (withMarkers) {
          result.addAll(node.markers);
        }
        loop(node.children);
      } else {
        result.add(node);
      }
    }
  }

  loop(children);
  return result;
}