to<T extends State<StatefulWidget>> static method

T? to<T extends State<StatefulWidget>>()

Retrieve the State object by type Returns null if not found Note: If there's multiple State objects of the same type, will return the 'last' state object added to the Map, _setStates"

Implementation

static T? to<T extends State>() {
  final state = _setStates.isEmpty ? null : _setStates[_type<T>()];
  T? result;
  if (state != null) {
    try {
      result = state as T;
    } catch (_) {
      result = null;
    }
  }
  return result;
}