dart format

Use the dart format command to replace the whitespace in your program with formatting that follows Dart guidelines. This is the same formatting that you can get when using an IDE or editor that has Dart support.

Provide a list of files or directories to the dart format command. For example, here’s how to format all the Dart files in or under the current directory:

$ dart format .

To specify multiple files or directories, use a space-delimited list. The following command formats all Dart files under the lib directory, plus one Dart file under the bin directory:

$ dart format lib bin/updater.dart 

If you don’t want to overwrite the files, add the -o flag. Use -o show or -o json to get the contents of the formatted files, or -o none to see only which files would change.

$ dart format -o show bin/my_app.dart

For information on additional command-line options, use the dart help command or see the documentation for the dart_style package.

$ dart help format

The dart format command replaces dartfmt.