findFocusedObject function
Utility helper methods
Finds the first focused focused child of root
using a breadth-first search.
Implementation
/// Finds the first focused focused child of [root] using a breadth-first search.
RenderObject? findFocusedObject(RenderObject? root) {
final q = Queue<RenderObject?>();
q.add(root);
while (q.isNotEmpty) {
final node = q.removeFirst()!;
final config = SemanticsConfiguration();
//ignore: invalid_use_of_protected_member
node.describeSemanticsConfiguration(config);
if (config.isFocused) {
return node;
}
node.visitChildrenForSemantics((child) {
q.add(child);
});
}
return null;
}