Open
Description
Use Case
In some contexts like AI prompts, developer tools, or code-sharing platforms, a compact version of Dart code would be more appropriate than the standard formatted version. Dart’s formatting is great for readability, but sometimes, a minified format is better for:
- Fitting code into token-limited AI prompts
- Sending snippets to a custom interpreter or browser-based tool
- Sharing short examples in a compressed form
Alternatives considered
- Manually removing whitespace — slow and error-prone
- Using production minification — not usable for readable source snippets
- There is no current tool or pub.dev package that provides a lightweight, syntax-preserving Dart minifier
Proposal
Add an optional Dart code minifier, similar to JavaScript minifiers, as a command-line tool or dart format flag:
dart format --minify lib/example.dart
Features could include:
- Stripping newlines and extra indentation
- Optionally shortening variable names (if feasible)
- Preserving syntax and logic, not intended for production builds
This tool would be very helpful in development workflows, AI integrations, and dev tooling. It should ideally be provided by Dart SDK, not a package, since it relates to the language’s formatting rules and syntax tree.