diff --git a/lib/src/lints/proper_super_calls/proper_super_calls_rule.dart b/lib/src/lints/proper_super_calls/proper_super_calls_rule.dart index c804d9e..166b736 100644 --- a/lib/src/lints/proper_super_calls/proper_super_calls_rule.dart +++ b/lib/src/lints/proper_super_calls/proper_super_calls_rule.dart @@ -89,9 +89,11 @@ class ProperSuperCallsRule extends SolidLintRule { context.registry.addMethodDeclaration( (node) { final methodName = node.name.toString(); + final body = node.body; - if (methodName == _initState || methodName == _dispose) { - final statements = (node.body as BlockFunctionBody).block.statements; + if (methodName case _initState || _dispose + when body is BlockFunctionBody) { + final statements = body.block.statements; _checkSuperCalls( node, diff --git a/lint_test/proper_super_calls_test.dart b/lint_test/proper_super_calls_test.dart index 2bc794b..0de343c 100644 --- a/lint_test/proper_super_calls_test.dart +++ b/lint_test/proper_super_calls_test.dart @@ -75,3 +75,7 @@ class MyClass { dispose() {} initState() {} } + +abstract interface class Disposable { + void dispose(); +}