prefer-explicit-parameter-names
Warns when parameter names in function types are omitted.
Parameter names are used by the IDE's code completion instead of default names like p0
and p1
. Therefore, providing them can improve the overall developer experience.
Example
❌ Bad:
class LayoutBuilder {
LayoutBuilder({this.builder});
final Widget Function(BuildContext, ConstraintType) builder; // LINT: Prefer declaring names for function type parameters.
}
✅ Good:
class LayoutBuilder {
LayoutBuilder({this.builder});
// Correct, have names
final Widget Function(BuildContext context, ConstraintType constraints) builder;
}