Skip to content
pubscout

dart_format

2.2.2, released 6 months ago by eggnstone.dev

Configurable Dart/Flutter formatter that never wraps lines unless requested

$ flutter pub add dart_format
Source repository

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.

  • cli_tools

    Utilities for building command‑line interfaces, including argument parsing, analytics, and progress reporting.

  • http_status_code

    A Dart library providing constants and helpers for HTTP status codes.

  • jsonc

    JSON parser that supports comments, trailing commas, and hexadecimal numbers

Works with

Packages commonly used together with dart_format: ones it builds on, ones built on it, and its own family.