I want to format my code but not sure what format type is best for my project needs.
I found out that for only dart and for flutter projects (I have both) there are more than one option to use for formatting the code that come pre built in the programming language/framework.
dartfmt:
dartfmt -w *
dart format:
dart format *
flutter format:
flutter format *
What is the difference, when should I use what, is there best practice.
They should all do the same thing (barring version differences, but that's no different than comparing dartfmt
from one SDK version to another).
dartfmt
is the original formatter. To try to provide a simpler, more unified command-line interface, a lot of Dart command-line tools are being packaged as subcommands of dart
(e.g. dartfmt
becomes dart format
, dartanalyzer
becomes dart analyze
, pub
becomes dart pub
), similar to how the flutter
script works, and dartfmt
is being deprecated.
flutter format
is just a wrapper around dart format
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With