This package allows using NumberFormat
of the intl
package together with BigDecimal
numbers.
Check out the pub.dev page for this package: https://pub.dev/packages/big_decimal_intl
First define a number format wrapped inside a BigDecimalFormatter
object:
final formatter = BigDecimalFormatter(NumberFormat.decimalPattern());
To format a number into at String
us the format
method:
final formatted = formatter.format(BigDecimal.parse('1.5'));
To parse a number from a String
use the parse
method:
final bigDecimal = formatter.parse('1.5');
With Dart:
$ dart pub add big_decimal_intl
With Flutter:
$ flutter pub add big_decimal_intl
Now in your Dart code, you can use:
import 'package:big_decimal_intl/big_decimal_intl.dart';
This package is a port of the intl part of dart-decimal for BigDecimal.