Please use dart-format-pre-commit. This package will give a Flutter warning to migrate to dart format
, which this other package is.
pre-commit
hook for formatting Flutter files.
Add the following in your .pre-commit-config.yaml
:
- repo: https://github.com/Cretezy/flutter-format-pre-commit
rev: "master"
hooks:
- id: flutter-format
By default, the flutter format command uses a line length of 80. You can customize what line length is used by passing the --line-length
argument to the hook:
- repo: https://github.com/Cretezy/flutter-format-pre-commit
rev: "master"
hooks:
- id: flutter-format
args: [--line-length=100]
You can also only include/exclude some files (defaults to only .dart
, is a pattern):
- repo: https://github.com/Cretezy/flutter-format-pre-commit
rev: "master"
hooks:
- id: flutter-format
files: lib/* # Only format source files
exclude: lib/src/avatar.dart # Exclude the avatar widget
Also see Dart Format pre-commit
for formatting only Dart code.