dart_currencies 2.0.0 copy "dart_currencies: ^2.0.0" to clipboard
dart_currencies: ^2.0.0 copied to clipboard

Data package containing currencies and information about them that helps formatting.

Data package containing currencies and information about them that helps formatting.

import 'package:dart_currencies/dart_currencies.dart';
import 'package:intl/intl.dart';

void main() {
  const usd = Currency.USD();
  final eur = Currency.fromCode(CurrencyCode.EUR);

  // formatting
  print(buildEnglishFormatter(usd).format(2500));
  print(buildEnglishFormatter(eur).format(2500));
  print(buildFrenchFormatter(eur).format(2500));
}

/// the formatters are from the intl library but prices work well with it.
NumberFormat buildFrenchFormatter(Currency currency) {
  return NumberFormat.currency(
    locale: 'fr',
    name: currency.code.name,
    symbol: currency.symbol,
  );
}

NumberFormat buildEnglishFormatter(Currency currency) {
  return NumberFormat.currency(
    locale: 'en',
    name: currency.code.name,
    symbol: currency.symbol,
  );
}
0
likes
150
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

Data package containing currencies and information about them that helps formatting.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

More

Packages that depend on dart_currencies