bool at(BuildContext context, { bool autofocus: false })

Whether the focus is current at the given context.

If autofocus is true, the given context will become focused if no other widget is already focused.

Source

static bool at(BuildContext context, { bool autofocus: false }) {
  assert(context != null);
  assert(context.widget != null);
  assert(context.widget.key != null);
  assert(context.widget.key is GlobalKey);
  _FocusScope focusScope = context.inheritFromWidgetOfExactType(_FocusScope);
  if (focusScope != null) {
    if (autofocus)
      focusScope._setFocusedWidgetIfUnset(context.widget.key);
    return focusScope.scopeFocused &&
           focusScope.focusedScope == null &&
           focusScope.focusedWidget == context.widget.key;
  }
  assert(() {
    if (debugOnlyFocusedKey?.currentContext == null)
      debugOnlyFocusedKey = context.widget.key;
    if (debugOnlyFocusedKey != context.widget.key) {
      throw new FlutterError(
        'Missing Focus scope.\n'
        'Two focusable widgets with different keys, $debugOnlyFocusedKey and ${context.widget.key}, '
        'exist in the widget tree simultaneously, but they have no Focus widget ancestor.\n'
        'If you have more than one focusable widget, then you should put them inside a Focus. '
        'Normally, this is done for you using a Route, via Navigator, WidgetsApp, or MaterialApp.'
      );
    }
    return true;
  });
  return true;
}