Formatting
The money class provides a simple way of formatting currency using a pattern.
When you create a Currency instance you can provide a default format pattern which is used to format a Money instance when you call Money.toString().
The CommonCurrencies have default formatters for each Currency which is consistent with that currencies standards.
In some cases you may however want to format a Money instances in a specific manner. In this case you can use:
Money.format(String pattern)
1
import 'package:money2/money2.dart';
2
final Currency usd = Currency.create('USD', 2);
3
Money one = Money.fromInt(100, usd);
4
print(one.format('S0'));
5
> $1
Copied!
Copy link