Reorder constructors and fields in code example on Effective Dart: Usage
page
#5463
Closed
1 task done
Labels
a.effective-dart
Relates to the best practices explained in Effective Dart
cl.wont-fix
Issue closed as it either can't be or won't be fixed
e1-hours
Can complete in < 8 hours of normal, not dedicated, work
from.page-issue
Reported in a reader-filed concern
p3-low
Valid but not urgent concern. Resolve when possible. Encourage upvote to surface.
st.triage.ltw
Indicates Lead Tech Writer has triaged
Page URL
https://dart.dev/effective-dart/usage.html
Page source
https://github.com/dart-lang/site-www/tree/main/src/effective-dart/usage.md
Describe the problem
The examples on the ‘Effective Dart: Usage’ page (https://dart.dev/effective-dart/usage) currently place fields before constructors. This is inconsistent with the Dart and Flutter style guides, which recommend placing constructors first in a class. This inconsistency could potentially lead to confusion for developers, especially those who frequently switch between Dart and Flutter projects.
Expected fix
Reorder the constructors in all examples on the ‘Effective Dart: Usage’ page to align with the Dart and Flutter style guides. Specifically, adhere to the guidelines from ‘sort_constructors_first’ (https://dart.dev/tools/linter-rules/sort_constructors_first).
Additional context
This issue was raised following a pull request (#5452) that aimed to align the examples with the official style guides. The discussion in the pull request highlighted the tradition of placing fields before constructors in Dart, which is more familiar to developers from other programming languages. However, given the close relationship between Dart and Flutter, it’s worth considering the impact of these stylistic differences on the developer experience. This issue aims to gather feedback from the community on this matter.
I would like to fix this problem.
The text was updated successfully, but these errors were encountered: