You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similar to how we can specify page_width in the formatter configuration:
formatter:
page_width: 123
It would be useful to have a way to opt into the new formatting rules while still using an older SDK version.
Why?
The new formatter is the standard starting from Dart 3.7.0. However, many public packages cannot update their minimum SDK version immediately due to compatibility constraints.
New packages are created every day with lower constraints, but adopting the new formatter from the start would prevent future large-scale refactors just for style consistency.
Having an option to enable the new formatting rules regardless of the SDK version would allow for a smoother transition and encourage consistency across packages.
Proposed Solution 1: Formatter Version Parameter
A possible way to enable this would be by allowing an explicit formatter.version parameter in pubspec.yaml:
formatter:
version: 3.7.0
This would give developers precise control over the formatting style they adopt.
Projects can lock in a specific formatter version, ensuring consistent formatting across teams.
Future releases of the formatter would not automatically change a project's formatting unless formatter.version is explicitly updated.
This approach allows teams to opt into new formatting rules without requiring an immediate SDK upgrade.
The text was updated successfully, but these errors were encountered:
I don't think we want users to have to write an explicit version, but, yes, we have talked about the capability to opt in to the new style while still on an older version. I hope it's OK with you, but I'm going to edit the title of this issue to refer to that feature more generally.
@munificent Yes, the new title is clearer. I’ve updated the description to provide more context and explain a bit better why specifying a version could be a good idea. I haven’t considered other approaches, so I’m not sure what to compare it with.
Something the proposal needs to handle is that old version of the formatter are not going to work with newer Dart version which introduce syntax changes since it is unlikely that new features gets written into older versions of the formatter.
So this is mostly relevant for cases where you want new formatter to work on code compatible with older version of Dart. It is not likely to work for the opposite case where you want to use the old formatter for Dart code compatible with a more recent version than the formatter are meant for.
Similar to how we can specify
page_width
in theformatter
configuration:It would be useful to have a way to opt into the new formatting rules while still using an older SDK version.
Why?
The new formatter is the standard starting from Dart 3.7.0. However, many public packages cannot update their minimum SDK version immediately due to compatibility constraints.
New packages are created every day with lower constraints, but adopting the new formatter from the start would prevent future large-scale refactors just for style consistency.
Having an option to enable the new formatting rules regardless of the SDK version would allow for a smoother transition and encourage consistency across packages.
Proposed Solution 1: Formatter Version Parameter
A possible way to enable this would be by allowing an explicit
formatter.version
parameter inpubspec.yaml
:This would give developers precise control over the formatting style they adopt.
formatter.version
is explicitly updated.The text was updated successfully, but these errors were encountered: