ofState<T extends StateX<StatefulWidget>> method

T? ofState<T extends StateX<StatefulWidget>>()
inherited

Retrieve the StateX object of type T Returns null if not found

Implementation

T? ofState<T extends StateX>() {
  StateX? state;
  if (_stateXSet.isEmpty) {
    state = null;
  } else {
    final stateList = _stateXSet.toList(growable: false);
    try {
      for (final item in stateList) {
        if (item is T) {
          state = item;
          break;
        }
      }
    } catch (_) {
      state = null;
    }
  }
  return state == null ? null : state as T;
}