pre-commit
hook for formatting Dart files.
Add the following in your .pre-commit-config.yaml
:
- repo: https://github.com/ll886/dart-format-pre-commit
rev: "master"
hooks:
- id: dart-format
You can also only include/exclude some files (defaults to only .dart
, is a pattern):
- repo: https://github.com/ll886/dart-format-pre-commit
rev: "master"
hooks:
- id: dart-format
files: lib/* # Only format source files
exclude: lib/src/utils.dart # Exclude utils
Also see Flutter Format pre-commit
for formatting Flutter code.