money2
6.3.1, released 3 weeks ago by onepub.dev
High-precision library for storing, parsing, formatting, and performing arithmetic on money.
What it does
Money2 provides fixed-decimal storage and operations for monetary values to prevent floating-point rounding errors. It supports multi-currency definitions, custom formatting patterns, exchange rate conversions, and JSON serialization.
AI-written summary of version 6.3.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building financial, e-commerce, or business applications requiring precise decimal arithmetic.
- You need to handle multiple currencies and safely format or parse monetary strings.
Skip it when
- You only need basic floating-point arithmetic without currency context.
Strengths
- Fixed-precision math avoids floating-point rounding surprises.
- Comprehensive built-in world currencies and custom currency definitions.
- Locale-agnostic pattern parsing and formatting.
Weaknesses
- Exchange rates must be managed and provided manually rather than fetched from live APIs.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
final usd = Currency.create('USD', 2);
final price = Money.fromIntWithCurrency(1000, usd);
final tax = price * 0.1;
final total = price + tax;
print(total); // $11.00Alternatives
Packages that do the same job and could replace money2.
- zxing2
Pure Dart library for encoding and decoding QR codes.
75Compare - jiffy
Parse, manipulate, query, and format dates and times in Dart and Flutter.
70Compare - byte_converter
High‑performance byte and data‑rate conversion with BigInt precision and built‑in localization.
68Compare - time_machine2
Comprehensive date and time library with support for timezones, calendars, cultures, and parsing.
59Compare
Works with
Packages commonly used together with money2: ones it builds on, ones built on it, and its own family.
- charactersmoney2 depends on itUnicode and grapheme cluster aware string manipulation operations for Dart.
- decimalmoney2 depends on itArbitrary-precision decimal arithmetic for Dart
- fixedmoney2 depends on itFixed decimal numbers with a fixed scale, stored as BigInts, supporting math, formatting and parsing.