firstChild<T extends Component> method

T? firstChild<T extends Component>()

Returns the first child that matches the given type T.

As opposed to children.whereType<T>().first, this method returns null instead of a StateError when no matching children are found.

Implementation

T? firstChild<T extends Component>() {
  final it = children.whereType<T>().iterator;
  return it.moveNext() ? it.current : null;
}