controllerAround function

DartType? controllerAround(
  1. AstNode node
)

The type of the class or the mixin around node: the controller, when node is in one.

Implementation

DartType? controllerAround(AstNode node) {
  final around = node.thisOrAncestorMatching(
    (node) => node is ClassDeclaration || node is MixinDeclaration,
  );
  final element = switch (around) {
    ClassDeclaration(:final declaredFragment) => declaredFragment?.element,
    MixinDeclaration(:final declaredFragment) => declaredFragment?.element,
    _ => null,
  };
  return element?.thisType;
}