visitDirectChildren method

  1. @override
bool visitDirectChildren(
  1. InlineSpanVisitor visitor
)
override

Calls visitor for each immediate child of this InlineSpan.

The immediate children are visited in the same order they are added to a ui.ParagraphBuilder in the build method, which is also the logical order of the child InlineSpans in the text.

The traversal stops when all immediate children are visited, or when the visitor callback returns false on an immediate child. This method itself returns a bool indicating whether the visitor callback returned true on all immediate children.

See also:

  • visitChildren, which performs preorder traversal on this InlineSpan if it has content, and all its descendants with content.

Implementation

@override
bool visitDirectChildren(InlineSpanVisitor visitor) {
  final List<InlineSpan>? children = this.children;
  if (children != null) {
    for (final InlineSpan child in children) {
      if (!visitor(child)) {
        return false;
      }
    }
  }
  return true;
}