Search packages, repositories and app categories

Package detailsv6.3.0

fixed

Fixed scale decimal numbers with mathematical operations, formatting and parsing.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
157K
Likes
12
Pub points
160

Install package

flutter pub add fixed

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The fixed package provides support for fixed-scale decimal numbers, enabling precise mathematical operations, formatting, and parsing. It ensures consistent decimal precision by representing numbers with a fixed number of decimal places, preventing floating-point inaccuracies. Ideal for financial calculations and scenarios requiring exact decimal arithmetic, it offers reliable addition, subtraction, multiplication, and division with proper rounding. The package supports multiple platforms including Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Financial calculations
  • Precise decimal arithmetic
  • Currency handling
  • Data serialization with fixed precision
  • Scientific computations requiring exact decimals

Key features

  • Fixed decimal scale
  • Accurate arithmetic operations
  • Built-in formatting and parsing
  • Support for large numbers
  • Cross-platform compatibility

Suitable for

  • Developers needing exact decimal math
  • Financial or accounting applications
  • Applications requiring consistent decimal representation
  • Teams avoiding floating-point errors

Considerations

  • Requires careful selection of scale factor
  • Limited to fixed precision only
  • May have performance overhead for heavy computation
  • Not suitable for arbitrary-precision needs

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

The Fixed package allows you to store and perform math on decimal numbers with a fixed scale (fixed no. of decimal places).

All amounts are stored as BigInts to allow precision math to be performed.

The features of Fixed are:

  • Fixed uses a selectable fixed scale (no. of decimal places)
  • Fixed provides a builtin formatter and parser Fixed.format(pattern)
  • Full set of mathematical opertors.
  • Fixed includes a convenience method Fixed.formatIntl(locale) which formats the number with the provided locale or the default locale if not provided.

Sponsors

Fixed is sponsored by OnePub, the Dart private package repository.

OnePub

You can create a Fixed instance from a number sources

var t1 = Fixed.fromNum(1); /// == 1.00
var t2 = Fixed.fromNum(1, decimalDigits: 3); /// == 1.000

var add = t1 + 10;
var multiply = t1 * t2;

var t3 = Fixed.parse("1.23356"); // == 1.23356, decimalDigits: 5

if (t1 == t2) // true
{
    print(t1.format('0.##')); // '1.00'
    print(t3.format('0.###')); // '1.123'
}

Full documentation can be found here.

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package