asRef<T extends ZenController> method

ControllerRef<T> asRef<T extends ZenController>({
  1. String? tag,
  2. bool isPermanent = false,
  3. ZenScope? scope,
})

Create a typed reference to this controller instance

Implementation

ControllerRef<T> asRef<T extends ZenController>({
  String? tag,
  bool isPermanent = false,
  ZenScope? scope,
}) {
  if (this is T) {
    if (scope != null) {
      scope.put<T>(this as T, tag: tag, isPermanent: isPermanent);
    } else {
      Zen.put<T>(this as T, tag: tag, isPermanent: isPermanent);
    }
    return ControllerRef<T>(tag: tag, scope: scope);
  }
  throw Exception('Controller is not of type $T');
}