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 under the current directory’s bin, lib, and test directories:

$ dart format bin lib test

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.