find method

WidgetbookNode? find(
  1. bool predicate(
    1. WidgetbookNode node
    )
)

Searches for a node that matches predicate in the sub-tree of this node.

Implementation

WidgetbookNode? find(
  bool Function(WidgetbookNode node) predicate,
) {
  if (predicate(this)) {
    return this;
  } else {
    return children //
        ?.map((child) => child.find(predicate))
        .firstWhere(
          (child) => child != null,
          orElse: () => null,
        );
  }
}