ofState<T extends StateX<StatefulWidget> > method
T?
ofState<T extends StateX<StatefulWidget> >()
inherited
Retrieve the StateX object by type 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;
}
}
// state = stateList.firstWhere((item) => item is T);
} catch (_) {
state = null;
}
}
return state == null ? null : state as T;
}