didChangeDependencies method

  1. @override
void didChangeDependencies()
override

Called when a dependency of this State object changes.

Implementation

@override
void didChangeDependencies() {
  super.didChangeDependencies();
  if (Zone.current[#isMeasuringIntrinsics] == true) return;
  final parentScope = Focus.of(context);
  if (parentScope != null) {
    if (_focusNode.parent != parentScope) {
      parentScope.addChild(_focusNode);
    }
    _attachedParent = parentScope;
  } else if (_attachedParent != null) {
    if (_focusNode.parent == _attachedParent) {
      _attachedParent!.removeChild(_focusNode);
    }
    _attachedParent = null;
  }
}