money2
  • Overview
  • Common Currencies
  • Creating a Currency
  • Registering a Currency
  • Parsing
  • Find a currency
  • Default format
  • Symbols
  • Separators
    • Decimal Separator
    • Group Separator
  • Creating Money
    • Money.parse
    • Currency.parse
    • Money.from
    • Currencies.parse
    • decimalDigits
  • Formatting
    • Formatting Patterns
  • Storing and Send
  • Exchange Rates
  • Comparison
  • Currency Predicates
  • Value Sign Predicates
  • Arithmetic Operations
  • Allocation
  • Money encoding/decoding
Powered by GitBook
On this page

Was this helpful?

  1. Separators

Group Separator

Numbers also use a group separator to help format large numbers by placing a separator every few digits. e.g. $100,000.00

In the English speaking world the comma (,) is used as the group separator however in large parts of the world the period (.) is used as the group separator.

Money2 use the English convention as default. To switch to the Euro style convention set the decimalSeparator and groupSeparator arguments when creating a currency.

You will also need to provide an appropriate pattern.

import 'package:money2/money2.dart';

   test('Group Separator', () {
      final euro = Currency.create('EUR', 2,
          symbol: '€',
          decimalSeparator: ',',
          groupSeparator: '.',
          pattern: 'S0,000.00');

      expect(euro.groupSeparator, equals('.'));
    });

Note: even if you have switched to alternate separators, Money2 patterns always use the '.' for a decimal separator and the ',' as the thousand group separator. This allows patterns to be shared amongst currencies.

PreviousDecimal SeparatorNextCreating Money

Last updated 28 days ago

Was this helpful?