dispose method
void
dispose()
Disposes of the focus node, detaching it from the tree.
Implementation
void dispose() {
if (hasFocus) {
FocusNode? nextTarget = parent;
if (parent != null) {
final siblings = [
for (final c in parent!.children)
if (c != this) c,
];
if (siblings.isNotEmpty) {
nextTarget = siblings.first;
}
}
FocusManager.instance.setPrimaryFocus(nextTarget);
}
final p = parent;
if (p != null) {
p.children.remove(this);
if (p is FocusScopeNode && p._focusedChild == this) {
p._focusedChild = p.children.isNotEmpty ? p.children.first : null;
}
parent = null;
}
}