Open
Description
Consistently structured class declarations are often regarded as not important but they sure improve code readability and a definite must-have for teams.
The most comprehensive guide on this topic is probably Style guide for Flutter repo. The suggested default order is quite detailed and potentially could be implemented as a conventional Flutter Style rule.
However not everyone may find such a structure appropriate for their project. For example, I find it odd that private methods used in build
should be listed before it. I'm new to Dart and honestly don't know if the Linter supports configurable rules, but in the ideal world it could look something like this:
# Uses flutter repo style by default
- class_members_ordering
# Custom order that potentially could be specified separately for different paths,
# e.g. `lib/models`, `lib/widgets` etc.
class_members_ordering:
- constructors
- factories
- instance_variables
# etc.
The rule is not specific to any Dart framework.