dispose method

  1. @override
void dispose()
override

Called when this object is removed from the tree permanently.

Implementation

@override
void dispose() {
  final p = _focusNode.parent;
  if (p != null) {
    // Clean up parenting relationship via removeChild instead of directly
    // mutating the parent's children list, which would bypass state propagation
    // and leave the parent node in an inconsistent state if this child had focus.
    p.removeChild(_focusNode);
  } else if (_focusNode.hasFocus) {
    _focusNode.unfocus();
  }
  if (widget.focusNode == null) {
    _focusNode.dispose();
  }
  super.dispose();
}