check method
void
check(
- DcqRegistry registry
)
Implementation
@override
void check(
DcqRegistry registry,
) {
registry.addMethodInvocation((node) {
final methodName = node.methodName.name;
if (methodName != 'of' && methodName != 'maybeOf') return;
final enclosingMethod = _findEnclosingMethod(node);
if (enclosingMethod == null) return;
if (enclosingMethod.name.lexeme != 'initState') return;
final bodyNode = enclosingMethod.parent;
if (bodyNode is! BlockClassBody) return;
final classDecl = bodyNode.parent;
if (classDecl is! ClassDeclaration) return;
final superclass = classDecl.extendsClause?.superclass;
if (superclass == null) return;
if (superclass.name.lexeme != 'State') return;
if (!isFromExpectedPackage(superclass, 'flutter')) return;
reportAtNode(node);
});
}