T currentState

The State for the widget in the tree that currently has this global key.

The current state is null if (1) there is no widget in the tree that matches this global key, (2) that widget is not a StatefulWidget, or the assoicated State object is not a subtype of T.

Source

T get currentState {
  Element element = _currentElement;
  if (element is StatefulElement) {
    StatefulElement statefulElement = element;
    State state = statefulElement.state;
    if (state is T)
      return state;
  }
  return null;
}