currency_formatter 1.0.1

Flutter Android iOS

A package to easily format money. It supports setting a custom currency symbol and format, using some of the inbuilt ones for the main currencies or using the system one.

currency_formatter #

A package to easily format money. It uses flutter_money_formatter and simplifies it.

Getting Started #

To set how a double will be formatted, create a CurrencyFormatterSettings:

CurrencyFormatterSettings euroSettings = CurrencyFormatterSettings(
  symbol:'€',
  symbolSide: SymbolSide.left,
  thousandSeparator: '.',
  decimalSeparator: ',',
);

symbolSide can be set to SymbolSide.left, SymbolSide.right, or SymbolSide.none. thousandSeparator and decimalSeparator default to '.', ',' or ',','.' automatically depending on symbolSide.

To format a num, CurrencyFormatter.format() is used:

CurrencyFormatter cf = CurrencyFormatter();
num amount = 1910.9347;
String formatted = cf.format(amount, euroSettings); // 1.910,93 €
String compact = cf.format(amount, euroSettings, compact: true); // 1,91K €
String threeDecimal = cf.format(amount, euroSettings, decimal: 3); // 1.910,945 €

Predefined settings for many currencies are also included in this package. They are listed in the CurrencyFormatter.majors variable and their symbols in CurrencyFormatter.majorSymbols. They can be used in both of the following ways which do exactly the same:

String inUSD = cf.format(amount, CurrencyFormatter.usd); // $ 1,910.93
  String inRUB = cf.format(amount, cf.majors['rub']); // 1.910,93 ₽

  String jpySymbol = cf.majorSymbols['jpy']; // ¥

In Flutter, you can get the default CurrencyFormatterSettings according to the device language using cf.getLocal():

String inSystemCurrency = cf.format(amount, cf.getLocal());

You can get a CurrencyFormatterSettings from a currency symbol (if it is in CurrencyFormatter.majors) with CurrencyFormatter.getFromSymbol():

String fromSymbol = cf.format(amount, cf.getFromSymbol('£')); // £ 1,910.35
0
likes
70
pub points
42%
popularity

A package to easily format money. It supports setting a custom currency symbol and format, using some of the inbuilt ones for the main currencies or using the system one.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

roman910dev@gmail.com

License

unknown (LICENSE)

Dependencies

flutter, flutter_money_formatter, intl

More

Packages that depend on currency_formatter