getChildByName method

  1. @override
DisplayObject? getChildByName(
  1. String name
)
override

Returns the child DisplayObject that exists with the specified name.

If more that one child DisplayObject has the specified name, the method returns the first object in the child list.

The getChildAt method is faster than the getChildByName method. The getChildAt method accesses a child from a cached array, whereas the getChildByName method has to traverse a list to access a child.

Implementation

@override
DisplayObject? getChildByName(String name) {
  for (var i = 0; i < _children.length; i++) {
    final child = _children[i];
    if (child.name == name) return child;
  }
  return null;
}