childIndexByName method

int childIndexByName(
  1. String name
)

Return the offset (index) of the child with name in children, or -1 if not found. Case-sensitive. O(1) after first call (lazily builds index).

Implementation

int childIndexByName(String name) {
  _childNameIndex ??= {
    for (var i = 0; i < children.length; i++) children[i].name: i,
  };
  return _childNameIndex![name] ?? -1;
}