unfocus method
inherited
Removes focus from a node that has the primary focus, and cancels any outstanding requests to focus it.
Calling requestFocus sends a request to the FocusManager
to make that
node the primary focus, which schedules a microtask to resolve the latest
request into an update of the focus state on the tree. Calling unfocus
cancels a request that has been requested, but not yet acted upon.
This method is safe to call regardless of whether this node has ever requested focus.
Has no effect on nodes that return true from hasFocus, but false from hasPrimaryFocus.
Implementation
void unfocus() {
if (hasPrimaryFocus) {
final FocusScopeNode scope = enclosingScope;
assert(scope != null, 'Node has primary focus, but no enclosingScope.');
scope._focusedChildren.remove(this);
_manager?._willUnfocusNode(this);
return;
}
if (hasFocus) {
// If we are in the focus chain, but not the primary focus, then unfocus
// the primary instead.
_manager.primaryFocus.unfocus();
}
}