Reorder constructors and fields in code example on Constructors
page
#5462
Labels
a.language
Relates to the Dart language tour
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/language/constructors.html
Page source
https://github.com/dart-lang/site-www/tree/main/src/language/constructors.md
Describe the problem
The examples on the ‘Constructors’ page (https://dart.dev/language/constructors) 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 ‘Constructors’ 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) and ‘Constructors come first in a class’ (https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#constructors-come-first-in-a-class).
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: