controllerByType<U extends StateXController> method

  1. @Deprecated('Proven to cause memory leaks.')
U? controllerByType<U extends StateXController>()

Retrieve a StateXController by type.

Implementation

@Deprecated('Proven to cause memory leaks.')
U? controllerByType<U extends StateXController>() {
  // Look in this State objects list of Controllers.  Maybe not?

  U? con = _cons[_type<U>()] as U?;

  if (con == null) {
    final controllers = rootState?._controllers.toList();
    if (controllers != null) {
      for (final cont in controllers) {
        if (cont.runtimeType == _type<U>()) {
          con = cont as U?;
          break;
        }
      }
    }
  }
  return con;
}