Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dartfmt vs dart format vs flutter format

Tags:

flutter

dart

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.

like image 874
Guy Luz Avatar asked Dec 30 '22 17:12

Guy Luz


1 Answers

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.

like image 84
jamesdlin Avatar answered Jan 31 '23 04:01

jamesdlin