of<T extends StatefulWidget, U extends State<StatefulWidget>> static method

U? of<T extends StatefulWidget, U extends State<StatefulWidget>>()

Retrieve the type of State object by its StatefulWidget Returns null if not found

Implementation

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