setFirstFocus method Null safety
- FocusScopeNode scope
Make the given scope
the active child scope for this scope.
If the given scope
is not yet a part of the focus tree, then add it to
the tree as a child of this scope. If it is already part of the focus
tree, the given scope must be a descendant of this scope.
Implementation
void setFirstFocus(FocusScopeNode scope) {
assert(scope != null);
assert(scope != this, 'Unexpected self-reference in setFirstFocus.');
assert(_focusDebug('Setting scope as first focus in $this to node:', <String>[scope.toString()]));
if (scope._parent == null) {
_reparent(scope);
}
assert(scope.ancestors.contains(this), '$FocusScopeNode $scope must be a child of $this to set it as first focus.');
if (hasFocus) {
scope._doRequestFocus(findFirstFocus: true);
} else {
scope._setAsFocusedChildForScope();
}
}