unregister method

void unregister(
  1. String id
)

Unregisters a focus ID.

Implementation

void unregister(String id) {
  if (TuiTrace.enabled) {
    TuiTrace.log(
      'focus.unregister id=$id wasFocused=${_focusedId == id} trapId=$_trapId savedFocus=$_savedFocusId',
    );
  }
  _parents.remove(id);
  _focusableIds.remove(id);
  // Clean children that referenced this ID as their parent — they are
  // orphaned now and leaving them causes stale ancestry chains that
  // break isDescendant() checks.
  _parents.removeWhere((_, parentId) => parentId == id);
  if (_focusedId == id) {
    _focusedId = null;
    _notify();
  }
  if (_trapId == id) {
    _trapId = null;
  }
  if (_savedFocusId == id) {
    _savedFocusId = null;
  }
}