Skip to content

Allow opting in to tall style for older language versions #1654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GiancarloCante opened this issue Feb 21, 2025 · 3 comments
Open

Allow opting in to tall style for older language versions #1654

GiancarloCante opened this issue Feb 21, 2025 · 3 comments

Comments

@GiancarloCante
Copy link

GiancarloCante commented Feb 21, 2025

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.
@munificent
Copy link
Member

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 munificent changed the title Add formatter.version Parameter to pubspec.yaml Allow opting in to tall style for older language versions Feb 26, 2025
@GiancarloCante
Copy link
Author

@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.

@julemand101
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants