Currency.parse

The simplest variant of Currency.parse relies on the default pattern of the currency.

  test('parse with Currency', () {
    /// Parse using a currency.
    var t1 = CommonCurrencies().aud.parse(r'$10.00');
    expect(t1.toString(), equals(r'$10.00'));
    expect(t1.currency.isoCode, equals('AUD'));
  });

You can also pass an explict pattern.

      test('Parse with pattern', () {
        final t2 = CommonCurrencies().aud.parse(r'10.00$', pattern: '0.00S');
        expect(t2.toString(), equals(r'$10.00'));
        expect(t2.currency.isoCode, equals('AUD'));
      });

Last updated

Was this helpful?