currency_formatter 1.2.1 copy "currency_formatter: ^1.2.1" to clipboard
currency_formatter: ^1.2.1 copied to clipboard

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.

example/example.dart

import 'package:currency_formatter/currency_formatter.dart';

void main() {
  CurrencyFormatter cf = CurrencyFormatter();

  CurrencyFormatterSettings euroSettings = CurrencyFormatterSettings(
    // formatter settings for euro
    symbol: '€',
    symbolSide: SymbolSide.left,
    thousandSeparator: '.',
    decimalSeparator: ',',
  );

  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,935 €

  num parseFormatted = cf.parse(formatted, euroSettings); // 1910.93
  num parseCompact = cf.parse(compact, euroSettings); // 1910.0
  num parseThreeDecimal = cf.parse(threeDecimal, euroSettings); // 1910.935

  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']!; // ¥

  String inSystemCurrency =
      cf.format(amount, cf.getLocal() ?? cf.majors['usd']!);

  String fromSymbol = cf.format(amount, cf.getFromSymbol('£')!); // £ 1,910.35
}
46
likes
130
points
6.46k
downloads

Publisher

verified publisherroman910.tk

Weekly Downloads

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)

Documentation

API reference

License

unknown (license)

Dependencies

flutter, intl

More

Packages that depend on currency_formatter