controllerByType<U extends ControllerMVC?> method

U? controllerByType<U extends ControllerMVC?>()

Retrieve a Controller in the widget tree by type. Retrieve a Controller in the MVC framework by type.

Implementation

//  T controllerByType<T extends ControllerMVC>(
//      [BuildContext context, bool listen = true]) {
//    T con;
//    if (context != null && listen) {
//      _InheritedMVC<Object> w =
//          context.dependOnInheritedWidgetOfExactType<_InheritedMVC<Object>>();
//      con = w?.object;
//    }
//    return con ?? _cons[_type<T>()];
//  }

/// Retrieve a Controller in the MVC framework by type.
U? controllerByType<U extends ControllerMVC?>() {
  // Look in this State objects list of Controllers.  Maybe not?
  // ignore: avoid_as
  U? con = _cons[_type<U>()] as U?;
  // ignore: avoid_as
  return con ??= AppMVC._controllers[_type<U>()] as U?;
}