-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-false-negativeIssues related to lint rules that fail to report a problem.Issues related to lint rules that fail to report a problem.linter-set-fluttertype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
prefer_const_constructors_in_immutables only triggers when an @immutable class has a non-const constructor. If no constructor is explicitly defined, the lint doesn't trigger and you - unfortunately - end up with an immutable class that cannot be const constructed. I think, the lint should remind people to add an explicit const constructor in those cases as well.
// 🔥 no reminder is given that this immutable class should have a const constructor.
@immutable
class Foo {
}
// lint triggers as expected.
@immutable
class Bar {
Bar();
}This could be relevant for some Flutter widgets that don't take in any arguments and because of this developers don't see a reason to add an explicit constructor. They are now missing an opportunity to create a const instance of their widget.
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-false-negativeIssues related to lint rules that fail to report a problem.Issues related to lint rules that fail to report a problem.linter-set-fluttertype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)