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
{{ message }}
Repository navigation
[flutter_tools] Deprecate flutter format sub-command in favor of dart format #115809
on Flutter's main branch, land a PR to add a deprecation warning to the flutter format sub-command, warning users that it will be removed in a future Flutter release and that all uses of it should be replaced by dart format with the same command line arguments
once the code from the previous step reaches a stable release, a new change can be made to main that fails with a non-zero exit code, again with directions to start using dart format. This will catch users who either did not see the deprecation warning or chose to ignore it.
once the code from the previous step reaches a stable release, the command can be deleted from main.
If at any point it is found that customers have a legitimate use of flutter format that cannot be trivially met by substituting dart format for flutter format, we can discuss reverting the change and restoring flutter format.
While I understand the reasoning behind this change, unfortunately there is now no full proof way of ensuring that formatting is run using the same version of dart format that is shipped with Flutter which means that there is a higher risk of getting results that are inconsistent e.g. between different developer machines or between a developer machine and CI.
To circumvent this, it would be great if we could at least get a way of reliably locating the Dart SDK inside the Flutter installation.
When using a system-wide installation of Flutter, this location might be predictable but this is not always the case. For example, I routinely have work on projects that support different minimum versions of Flutter, and I manage these using asdf-vm, which means that e.g. which flutter will always return $HOME/.asdf/shims/flutter and there might be others on my team using similar solutions.
While I understand the reasoning behind this change, unfortunately there is now no full proof way of ensuring that formatting is run using the same version of dart format that is shipped with Flutter which means that there is a higher risk of getting results that are inconsistent e.g. between different developer machines or between a developer machine and CI.
To circumvent this, it would be great if we could at least get a way of reliably locating the Dart SDK inside the Flutter installation.
When using a system-wide installation of Flutter, this location might be predictable but this is not always the case. For example, I routinely have work on projects that support different minimum versions of Flutter, and I manage these using asdf-vm, which means that e.g. which flutter will always return $HOME/.asdf/shims/flutter and there might be others on my team using similar solutions.
@tjarvstrand thanks for raising this concern. The officially recommended way to setup the Flutter SDK is to add flutter/bin to your PATH variable: https://github.com/flutter/flutter/blob/master/bin/dart. This directory includes a bash (and batch) entrypoint that will ensure you are using the version of the Dart SDK that is vendored with the Flutter SDK. Also note that flutter doctor -v will test if this path is on your path, and give you a hint as to the path to add if it is not. I would recommend using this Dart entrypoint in order to format Dart code.
@tjarvstrand thanks for raising this concern. The officially recommended way to setup the Flutter SDK is to add flutter/bin to your PATH variable: https://github.com/flutter/flutter/blob/master/bin/dart. This directory includes a bash (and batch) entrypoint that will ensure you are using the version of the Dart SDK that is vendored with the Flutter SDK. Also note that flutter doctor -v will test if this path is on your path, and give you a hint as to the path to add if it is not. I would recommend using this Dart entrypoint in order to format Dart code.
I'm afraid that takes a rather narrow view of how developers can be expected to set up their environments. Even if you put this bin-directory on your PATH, you have to also make sure it's the first directory containing a dart-executable. I realize that this probably won't change because of my complaining here but I just want to say that I think that will make things very inconvenient for a lot of people. A simple flutter dart ... command would make things so much easier.
Even if you put this bin-directory on your PATH, you have to also make sure it's the first directory containing a dart-executable
The doctor validator does validate what binary is resolved from the path, so at least it would catch this situation.
A simple flutter dart ... command would make things so much easier.
that's a good idea :). If you file a feature request for that and tag me we can start discussing. I would need to give more thought on the implications of that and how to do it right, but off-hand that sounds very reasonable to me.
that's a good idea :). If you file a feature request for that and tag me we can start discussing. I would need to give more thought on the implications of that and how to do it right, but off-hand that sounds very reasonable to me.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
christopherfujino commentedon Dec 1, 2022
Deprecation warning was added in #116145
InMatrix commentedon Dec 7, 2022
Are we tracking the # of invocations of
flutter formatanddart format? If this migration is successful, this total # shouldn't change much.tjarvstrand commentedon May 14, 2023
Hello!
While I understand the reasoning behind this change, unfortunately there is now no full proof way of ensuring that formatting is run using the same version of
dart formatthat is shipped with Flutter which means that there is a higher risk of getting results that are inconsistent e.g. between different developer machines or between a developer machine and CI.To circumvent this, it would be great if we could at least get a way of reliably locating the Dart SDK inside the Flutter installation.
When using a system-wide installation of Flutter, this location might be predictable but this is not always the case. For example, I routinely have work on projects that support different minimum versions of Flutter, and I manage these using asdf-vm, which means that e.g.
which flutterwill always return$HOME/.asdf/shims/flutterand there might be others on my team using similar solutions.christopherfujino commentedon May 30, 2023
@tjarvstrand thanks for raising this concern. The officially recommended way to setup the Flutter SDK is to add flutter/bin to your PATH variable: https://github.com/flutter/flutter/blob/master/bin/dart. This directory includes a bash (and batch) entrypoint that will ensure you are using the version of the Dart SDK that is vendored with the Flutter SDK. Also note that
flutter doctor -vwill test if this path is on your path, and give you a hint as to the path to add if it is not. I would recommend using this Dart entrypoint in order to format Dart code.christopherfujino commentedon May 30, 2023
As this command has already been deprecated on stable, we can now delete it: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/format.dart
tjarvstrand commentedon May 31, 2023
I'm afraid that takes a rather narrow view of how developers can be expected to set up their environments. Even if you put this bin-directory on your PATH, you have to also make sure it's the first directory containing a dart-executable. I realize that this probably won't change because of my complaining here but I just want to say that I think that will make things very inconvenient for a lot of people. A simple
flutter dart ...command would make things so much easier.christopherfujino commentedon May 31, 2023
The doctor validator does validate what binary is resolved from the path, so at least it would catch this situation.
that's a good idea :). If you file a feature request for that and tag me we can start discussing. I would need to give more thought on the implications of that and how to do it right, but off-hand that sounds very reasonable to me.
tjarvstrand commentedon Jun 2, 2023
Thanks! I opened a request for it.
[flutter_tools] delete flutter format command (#129360)
github-actions commentedon Jul 6, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.