Guy Luz
Guy Luz

Reputation: 4009

dartfmt vs dart format vs flutter format

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.

Upvotes: 8

Views: 6292

Answers (1)

jamesdlin
jamesdlin

Reputation: 89995

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.

Upvotes: 18

Related Questions