prefer-named-parameters
- Group
- Style
- Path
lint/style/prefer-named-parameters- Default
- Off, opt in
- Origin
- Falcon
- Rule
- 390 of 512
Prefer named parameters when a declaration exceeds max-number (default 1).
Checks top-level functions, constructors, and methods on classes without
inheritance. Overrides, operators, setters, closures, function types, main,
external/annotated declarations, redirects and super-parameter constructors
are excluded because their signatures can be imposed by another declaration.
Invalid
void configure(int width, int height, String label) {}
class Box {
Box(int width, int height, String label);
void resize(int width, int height, bool animate) {}
}void configure(int width, int height, String label) {}class Box { Box(int width, int height, String label); Box(int width, int height, String label); void resize(int width, int height, bool animate) {}Valid
void configure(int width, int height, {required String label}) {}
void optional(int width, [int height = 0]) {}
class Base {
void resize(int width, int height) {}
}
class Child extends Base {
@override
void resize(int width, int height) {}
void inheritedContext(int a, int b, int c) {}
}
final callback = (int a, int b, int c) {};
typedef Callback = void Function(int a, int b, int c);
void main(List<String> args, Object? message) {}
external int nativeFunction(int a, int b, int c);
@deprecated
void annotated(int a, int b, int c) {}
class Redirect {
factory Redirect(int a, int b, int c) = Target;
}
class Target implements Redirect {
@deprecated
Target(int a, int b, int c);
}
class Parent {
@deprecated
Parent(int a, int b, int c);
}
class SuperChild extends Parent {
SuperChild(super.a, super.b, super.c);
}Configure prefer-named-parameters
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"prefer-named-parameters": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/prefer-named-parameters: <reason>More style rules
- prefer-null-aware-method-calls
prefer_null_aware_method_callsrecommendedPrefers
f?.call()to calling a null-checked function after a!= nulltest. - prefer-padding-over-containerflutter
Prefers
Paddingover aContainerused only forpadding. - prefer-provider-extensionsprovider
Prefer context.read/watch when provider extensions are in scope.
- prefer-returning-condition
Flags an
ifreturning a boolean literal followed by the opposite literal. - prefer-riverpod-notifier-suffixriverpod
Requires a
Notifiersuffix on classes extending resolved Riverpod notifiers. - prefer-riverpod-provider-suffixriverpod
Requires a Provider suffix on resolved Riverpod top-level providers and static fields.
- prefer-single-quotes
prefer_single_quotesFlags double-quoted string literals that could use single quotes without needing an escape.
- prefer-sized-box-squareflutter
Prefers SizedBox.square for an unnamed Flutter
SizedBoxwhose explicit width and height are stable variable reads or numeric literals with identical token spelling.