check method
void
check(
- DcqRegistry registry
)
Implementation
@override
void check(
DcqRegistry registry,
) {
registry.addMethodDeclaration((node) {
final methodName = node.name.lexeme;
if (methodName != 'initState' && methodName != 'dispose') return;
if (!_isInStateClass(node)) return;
final body = node.body;
if (body is! BlockFunctionBody) return;
final statements = body.block.statements;
if (statements.isEmpty) return;
if (methodName == 'initState') {
if (!_isSuperCall(statements.first, 'initState')) {
reportAtToken(node.name);
}
} else if (methodName == 'dispose') {
if (!_isSuperCall(statements.last, 'dispose')) {
reportAtToken(node.name);
}
}
});
}