fixed 6.0.0 copy "fixed: ^6.0.0" to clipboard
fixed: ^6.0.0 copied to clipboard

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

example/fixed_example.dart

/* Copyright (C) Brett Sutton - All Rights Reserved
 * Released under the MIT license.
 * Written by Brett Sutton <bsutton@onepub.dev>, Jan 2022
 */

import 'package:fixed/fixed.dart';

void main() {
  final fixed = Fixed.fromNum(1, decimalDigits: 2); // == 1.00

  Fixed.parse('1.234', decimalDigits: 2); // == 1.23;

  Fixed.parse('1,000,000.234', decimalDigits: 2); // == 1000000.23

  /// decimal separator is ','.
  Fixed.parse('1.000.000,234',
      decimalDigits: 2, invertSeparator: true); // == 1000000.23

  /// us minor units
  Fixed.fromInt(1234, decimalDigits: 3); // == 1.234

  /// use default formatting
  print(fixed);

  /// control the formatted output
  print(fixed.format('#.#'));
  print(fixed.format('#.000'));

  final add = fixed + Fixed.fromNum(1);
  print(add);
}
7
likes
150
points
62.3k
downloads

Publisher

verified publisheronepub.dev

Weekly Downloads

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

Repository (GitHub)

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

decimal, intl, meta

More

Packages that depend on fixed