Skip to main content

prefer-named-parameters

added in: 1.18.0
⚙️
Pro+

Suggests converting positional parameters to named parameters when a declaration has a certain number of positional parameters.

⚙️ Config

Set max-number (default is 1) to configure the number of allowed positional parameters.

dart_code_metrics:
...
rules:
...
- prefer-named-parameters:
max-number: 3

Example

❌ Bad:

class Some {
final String value;
final String another;

const Some(this.value, this.another); // LINT
}

✅ Good:

class Some {
final String value;
final String another;

const Some(this.value, {required this.another});
}