visitSVGTree function

dynamic visitSVGTree(
  1. Pointer<NativeGumboNode> node,
  2. dynamic visitor(
    1. Pointer<NativeGumboNode>,
    2. dynamic
    ), [
  3. dynamic parentValue
])
  • You can return value in visitor.
    • false is skip the children
    • others is treat as the parentValue

Implementation

dynamic visitSVGTree(
    Pointer<NativeGumboNode> node,
    // ignore: avoid_annotating_with_dynamic
    dynamic Function(Pointer<NativeGumboNode>, dynamic) visitor,
    [parentValue]) {
  final currentValue = visitor(node, parentValue);
  if (currentValue == false) {
    return;
  }
  final type = node.ref.type;
  if (type == GumboNodeType.GUMBO_NODE_ELEMENT) {
    final element = node.ref.v.element;
    final children = element.children;
    for (int i = 0; i < children.length; i++) {
      final childRef = children.data[i] as Pointer<NativeGumboNode>;
      visitSVGTree(childRef, visitor, currentValue);
    }
  }

  return currentValue;
}