ofState<T extends State<StatefulWidget>> method

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

Retrieve the State object by type Returns null if not found

Implementation

T? ofState<T extends State>() {
  State? state;
  if (_stateMVCSet.isEmpty) {
    state = null;
  } else {
    final stateList = _stateMVCSet.toList(growable: false);
    state = stateList.firstWhere((item) => item is T);
  }
  // ignore: avoid_as
  return state == null ? null : state as T;
}