Skip to main content

avoid-nested-records

added in: 1.5.0
⚙️
Dart 3.0+
preset: recommended

Warns when a record type declaration contains a nested record type declaration.

⚙️ Config

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

dart_code_metrics:
...
rules:
...
- avoid-nested-records:
acceptable-level: 2

Example

❌ Bad:

typedef NullableRecord = ((({String str, Future<void> hello}),),); // LINT

(int, (int, (int,))) triple() => (...); // LINT

(int, (int, (int, (int,)))) quadruple() => (...); // LINT

✅ Good:

typedef NullableRecord = ({String str, Future<void> hello});

(int, int, int) triple() => (...);

(int, int, int, int) quadruple() => (...);