getChildAtLevel method

DeepNavigationNode<T> getChildAtLevel(
  1. int searchLevel
)

Returns the descendant of this node with searchLevel, which can be itself if searchLevel = level

Will error out if searchLevel is < level, which means that searchLevel is a parent of this.

Will also error out if there is no descendant at searchLevel

Implementation

DeepNavigationNode<T> getChildAtLevel(int searchLevel) {
  final child = tryChildAtLevel(searchLevel);
  if (child == null) {
    throw ArgumentError('No child at $searchLevel');
  }
  return child;
}