format
4.1.0, released 3 months ago by yet-another.dev
Dart string formatting with Python-style braces and printf mini-languages.
WASM-ready
What it does
Provides Python-style brace formatting and printf-style functions for Dart strings. It supports positional and named values, Unicode-aware alignment, locale-aware numbers, and custom formatters.
AI-written summary of version 4.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need Python-style string formatting or printf equivalents in Dart.
- You want advanced numeric padding, alignment, and grouping options without pulling in heavy internationalization packages.
Skip it when
- You only need basic string interpolation (which Dart supports natively).
- You are relying on legacy 1.6.0 patterns like string extensions or ambient global intl state without passing format configurations.
Strengths
- High performance with compiled and cached templates.
- Supports both Python-style braces and C-style printf mini-languages.
- Immutable configuration objects allow thread-safe locale and custom formatter handling.
Weaknesses
- Error hierarchy is separate from dart:core's FormatException, requiring explicit catch blocks for FormattingException.
- Does not include built-in intl locale support out of the box (requires package:format_intl for advanced intl integration).
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:format/format.dart';
void main() {
format('{} {}', 'hello', 'world');
format('{:08d}', 42);
}Alternatives
Packages that do the same job and could replace format.
- flutter_locales
Easily localize Flutter apps using JSON files with dynamic locale switching and persistent storage.
51Compare
Works with
Packages commonly used together with format: ones it builds on, ones built on it, and its own family.