To make the command have an exit code of 1 if any formatting changes occur, add the --set-exit-if-changed flag. This exit code is often used with continuous integration (CI) to indicate that a check should fail.

$ dart format -o none --set-exit-if-changed bin/my_app.dart

使用 --help 命令行参数或者查阅 dart_style Package 文档可以查看更多命令行选项。

$ dart help format