dart_format
2.2.2, released 6 months ago by eggnstone.dev
Configurable Dart/Flutter formatter that never wraps lines unless requested
What it does
Formats Dart and Flutter source code according to user‑defined rules such as brace placement, spacing, and indentation. It can run as a CLI, read from stdin, or expose a long‑running HTTP service used by IDE plugins.
AI-written summary of version 2.2.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Formatting code in CI or pre‑commit hooks
- Integrating formatting into IDEs via JetBrains or VS Code extensions
- Customizing line breaks and spacing beyond the default dart format
Skip it when
- You prefer the opinionated built‑in dart format
- You need a formatter that automatically wraps lines at a column limit
Strengths
- Fully configurable via JSON
- Never inserts line breaks unless explicitly enabled
- Supports CLI, stdin, and HTTP service for editor integration
- Preserves original line endings (CRLF/LF)
Weaknesses
- Not part of the Dart SDK, requires separate installation
- No automatic line‑wrapping feature
- Limited to formatting, no linting or analysis
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 9
Run `dart pub global activate dart_format` and add the executable to PATH. No additional permissions or build_runner needed.
```sh
# Format a single file
dart_format lib/main.dart
# Format all .dart files under lib/ and test/
dart_format lib test
```Alternatives
Packages that do the same job and could replace dart_format.
- dart_style
Provides an API and CLI to format Dart source code automatically.
89Compare - cli_tools
Utilities for building command‑line interfaces, including argument parsing, analytics, and progress reporting.
83Compare - http_status_code
A Dart library providing constants and helpers for HTTP status codes.
39Compare - jsonc
JSON parser that supports comments, trailing commas, and hexadecimal numbers
45Compare
Works with
Packages commonly used together with dart_format: ones it builds on, ones built on it, and its own family.
- analyzerdart_format depends on itPerforms static analysis of Dart code for tool integration and embedding.
- mimedart_format depends on itUtilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.
- globdart_format depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- json_annotationdart_format depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- argsdart_format depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- intldart_format depends on itA Dart library for internationalization and localization, providing message translation, plural/gender handling, and date/number formatting.
- freezed_annotationdart_format depends on itAnnotations for the freezed code-generator.