arguments_ordering
This rule flags a call whose named arguments are not in the configured order.
A call site with a dozen named arguments is a lookup table, and an unordered one has to be read end to end to answer “is this already set?”. Ordering keeps a diff honest too: a new argument lands in the middle where it can be seen, rather than appended beside a near-duplicate nobody noticed.
Positional arguments are never ordered, since their order is the call’s meaning and reordering them changes what it does.
This rule is in the pedantic preset. That preset supplies
order: alphabetical and lowers min_arguments to 2; outside it the rule
stays silent until an order is configured.
buildCard( elevation: 2, color: Colors.white, padding: EdgeInsets.zero, margin: EdgeInsets.zero, borderRadius: BorderRadius.zero,)buildCard( borderRadius: BorderRadius.zero, color: Colors.white, elevation: 2, margin: EdgeInsets.zero, padding: EdgeInsets.zero,)Enabling this rule
Section titled “Enabling this rule”Outside preset: pedantic, this rule reports nothing until you choose an order:
rules: arguments_ordering: order: alphabeticalOptions
Section titled “Options”many_lints: rules: arguments_ordering: order: alphabetical min_arguments: 5rules: arguments_ordering: order: alphabetical min_arguments: 5| Option | Type | Default | Description |
|---|---|---|---|
order |
string | — |
alphabetical, alphabetical_case_sensitive or by_length. Unset means the rule is silent |
min_arguments |
int | 5 |
How many named arguments a call needs before order is checked |
Turning this rule off
Section titled “Turning this rule off”To disable this rule:
rules: arguments_ordering: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”initializers_ordering— Keep constructor initializers in field order.map_keys_ordering— Keep map literal keys in a configured order.member_ordering— Keep class members in a configured order.parameters_ordering— Keep named parameters in a configured order.