getController method

dynamic getController(
  1. dynamic controller
)

Find a controller

Implementation

dynamic getController(dynamic controller) {
  if (controller == null) return null;

  dynamic controllerValue = _controllerDecoders[controller];
  if (controllerValue == null) {
    if (!_singletonControllers.containsKey(controller)) return null;
  }

  if (_singletonControllers.containsKey(controller)) {
    return _singletonControllers[controller];
  }

  if (controllerValue is NyController) return controllerValue;

  dynamic controllerFound = controllerValue();
  if (controllerFound is! NyController) return null;

  if (controllerFound.singleton) {
    _singletonControllers[controller] = controllerFound;
    return _singletonControllers[controller];
  }
  return controllerFound;
}