dart_style
3.1.14, released 5 weeks ago by tools.dart.dev
Provides an API and CLI to format Dart source code automatically.
What it does
Rewrites Dart code to follow the official Dart style guide, handling indentation, line wrapping, and punctuation. It can be used as a library or via the `dart format` command.
AI-written summary of version 3.1.14, based on the package's README and metadata. Report an inaccuracy
Use it when
- Enforcing consistent code style in a project
- Running formatting in CI or pre‑commit hooks
Skip it when
- Needing runtime code transformation
- When you require linting beyond formatting
Strengths
- Official package from the Dart team
- Works with the Dart SDK `dart format` command
- Configurable via analysis options
Weaknesses
- Only formats code, no linting or analysis
- Limited configuration options
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 8
import 'package:dart_style/dart_style.dart';
void main() {
final formatter = DartFormatter();
print(formatter.format('class A{void m(){}}'));
}Alternatives
Packages that do the same job and could replace dart_style.
- hotreloader
Automatic hot code reloader for Dart projects that applies file changes to the running process.
70Compare - cli_tools
Utilities for building command‑line interfaces, including argument parsing, analytics, and progress reporting.
83Compare - flutter_patcher
Self-hosted OTA hotfix tool for Flutter with signed code and asset patches.
65Compare - dart_format
Configurable Dart/Flutter formatter that never wraps lines unless requested
54Compare
Works with
Packages commonly used together with dart_style: ones it builds on, ones built on it, and its own family.
- analyzerdart_style depends on itPerforms static analysis of Dart code for tool integration and embedding.
- yamldart_style depends on itA Dart library for parsing YAML documents into Dart data structures.
- pub_semverdart_style depends on itVersions and version constraints implementing pub's versioning policy.
- package_configdart_style depends on itRead and write Dart package configuration files.
- source_spandart_style depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- argsdart_style depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- pubspec_parseSame familyParse pubspec.yaml files with a type‑safe API and detailed error reporting.
- coverageSame familyCollects, manipulates, and formats code coverage data in Dart