controller property

T get controller

Implementation

T get controller {
  // 1. Stack peek — innermost active ZenView instance for this type
  final stacked = _ZenViewRegistry.peek<T>();
  if (stacked != null) return stacked;

  // 2. Explicit scope override
  final s = scope;
  if (s != null) {
    final found = s.find<T>(tag: tag);
    if (found != null) return found;
  }

  // 3. Global DI fallback (e.g., controller registered before navigation)
  final global = Zen.findOrNull<T>(tag: tag);
  if (global != null) return global;

  throw ZenControllerNotFoundException(typeName: T.toString());
}