dartfmt

Use the dartfmt command to replace the whitespace in your programwith formatting that followsDart guidelines.This is the same formatting that you can getwhen using an IDE or editor that has Dart support.

Provide a list of files or directories to the dartfmt command.For example, here’s how to format all the Dart filesunder the current directory’s bin, lib, and test directories:

  1. $ dartfmt -w bin lib test

If you don’t want to overwrite the files,omit the -w option.The resulting source code is displayed to standard output.

  1. $ dartfmt bin/main.dart
  2. import 'package:my_app/my_app.dart' as my_app;
  3. main(List<String> arguments) {
  4. print('Hello world: ${my_app.calculate()}!');
  5. }
  6. $

For information on additional command-line options,use the —help flag or see the documentation for thedart_style package.

  1. $ dartfmt --help