isFocused method

bool isFocused(
  1. String id, {
  2. bool searchPath = false,
})

Returns true when id matches the current focus.

When searchPath is true, returns true if id is an ancestor of the currently focused widget.

Implementation

bool isFocused(String id, {bool searchPath = false}) {
  if (_focusedId == id) return true;
  if (searchPath && _focusedId != null) {
    var current = _focusedId;
    while (current != null) {
      if (current == id) return true;
      current = _parents[current];
    }
  }
  return false;
}