attach method

  1. @visibleForTesting
void attach(
  1. SemanticsOwner owner
)

Mark this node as attached to the given owner.

Implementation

@visibleForTesting
void attach(SemanticsOwner owner) {
  assert(_owner == null);
  _owner = owner;
  while (owner._nodes.containsKey(id)) {
    // Ids may repeat if the Flutter has generated > 2^16 ids. We need to keep
    // regenerating the id until we found an id that is not used.
    _id = _generateNewId();
  }
  owner._nodes[id] = this;
  owner._detachedNodes.remove(this);
  if (_dirty) {
    _dirty = false;
    _markDirty();
  }
  if (_children != null) {
    for (final SemanticsNode child in _children!) {
      child.attach(owner);
    }
  }
}