-
Notifications
You must be signed in to change notification settings - Fork 29.3k
Description
Use case
Developers create new widgets frequently. Many of these widgets are not designed for inheritance.
By suggesting final, we prevent accidental subclassing, making the widget safer and signaling the intended use clearly.
Improves code readability and maintainability by indicating immutability at the class level.
Could potentially optimize performance, as Dart may optimize final classes better in certain scenarios.
Proposal
Currently, when creating a new Widget class in Flutter, IDEs and templates do not suggest using the final keyword for the class.
Most Widgets are not intended to be subclassed, and marking them as final improves code safety and can have minor performance benefits.
The proposal is to add a suggestion or template update in Flutter tools and IDEs so that when developers create a new Widget, the final keyword is recommended or auto-inserted.