/dart-format-pre-commit

Format Dart code with pre-commit

Primary LanguageShellMIT LicenseMIT

Dart Format pre-commit

pre-commit hook for formatting Dart files.

Add the following in your .pre-commit-config.yaml:

- repo: https://github.com/Cretezy/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/Cretezy/dart-format-pre-commit
  rev: "master"
  hooks:
    - id: dart-format
      files: lib/* # Only format source files
      exclude: lib/src/utils.dart # Exclude utils

Flutter

Also see Flutter Format pre-commit for formatting Flutter code.