Skip to content
pubscout

currency_type

1.0.0, released 2 years ago by tantowi.com

A Dart type for precise financial values with exactly four decimal places.

WASM-ready
$ flutter pub add currency_type
Source repository

What it does

Provides a Currency class that stores amounts as integers to avoid floating‑point rounding errors. Supports arithmetic, comparison and parsing from numbers or strings, handling very large values accurately.

AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Need exact financial calculations without rounding errors
  • Working with large monetary values that exceed double precision

Skip it when

  • Require locale‑aware currency formatting or variable fractional digits
  • Performance‑critical code where custom numeric types add overhead

Strengths

  • Eliminates floating‑point rounding issues
  • Handles very large numbers precisely
  • Simple API for arithmetic and parsing

Weaknesses

  • Fixed to four fractional digits only
  • No built‑in formatting or locale support
  • Limited to monetary use‑case

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:currency_type/currency_type.dart';

void main() {
  var a = Currency.parse('0.7');
  var b = Currency.parse('0.49');
  var c = a * a;
  print('\$a * \$a = \$c'); // 0.7000 * 0.7000 = 0.4900
  print(c == b ? 'Equal' : 'Not Equal'); // Equal
}

Alternatives

Packages that do the same job and could replace currency_type.

  • result_type

    A Result type representing success or failure in Dart

  • time

    Type-safe DateTime and Duration calculations, powered by extensions.