Skip to main content

avoid-nested-extension-types

added in: 1.15.0
⚙️
Dart 3.3+

Warns when the representation field of an extension type is also an extension type.

⚙️ Config

Set acceptable-level (default is 2) to configure the acceptable nesting level.

dart_code_metrics:
...
rules:
...
- avoid-nested-extension-types:
acceptable-level: 2

Example

❌ Bad:

extension type ET1(String s) {}

extension type ET2(ET1 inner) {}

extension type ET3(ET2 inner) {} // LINT

✅ Good:

extension type ET1(String s) {}

extension type ET2(ET1 inner) {}