-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
If the default values for super parameters in a subclass are the same as in the super class, they don't have to be repeated as they will be copied from the super constructor. A lint could remind people that the repetition is unnecessary to keep it DRY.
Examples
Bad:
class Bar extends Foo {
Bar({super.value = true}); // Lint on this line that "= true" isn't necessary.
}
class Foo {
Foo({this.value = true});
final bool value;
}Good:
class Bar extends Foo {
Bar({super.value});
}
class Foo {
Foo({this.value = true});
final bool value;
}Also ok:
class Bar extends Foo {
Bar({super.value = false}); // Don't lint because the default was changed.
}
class Foo {
Foo({this.value = true});
final bool value;
}Additional context
Rules about copying the default value from the associated super-constructor: https://github.com/dart-lang/language/blob/master/working/1855%20-%20super%20parameters/proposal.md#parameter-types-and-default-values
Metadata
Metadata
Assignees
Labels
devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bug