money2
Search…
Common Currencies
Money2 ships with a list of Common Currencies with a default format, scale, code and symbol.
If your currency isn't in the list then please help by submitting a PR.
The Common Currencies are pre-registered allow you to easily access them their currency code or by a member field.
The $ character is used by Dart for String interpolation. When using a $ in your string mark the String as a raw String to avoid escaping: e.g. r'$1.00' vs '\$1.00'.
To create a Money instance from a common currency:
1
import 'package:money2/money2.dart';
2
import 'package:test/test.dart';
3
4
void main() {
5
test('Common Currency - example 1', () {
6
/// Create a Money instance from the AUD common currency.
7
final amount = Money.parse(r'$1.25', code: 'AUD');
8
expect(amount.toString(), equals(r'$1.25'));
9
expect(amount.format('SCCC 0.00'), equals(r'$AUD 1.25'));
10
11
/// Create a Money instance using the aud field.
12
final amount2 = Money.parseWithCurrency(r'$1.25', CommonCurrencies().aud);
13
expect(amount2.format('SCC 0.00'), equals(r'$AU 1.25'));
14
15
/// Create a money instance from a Fixed decimal and the USD
16
/// common currency.
17
final amount3 = Money.fromFixed(Fixed.parse('1.24', scale: 2), code: 'USD');
18
19
expect(amount3.format('S0.00 CCC'), equals(r'$1.24 USD'));
20
});
21
}
Copied!
Here is the list of currencies available in CommonCurrenciesbut please check the CommonCurrencies class as the list is updated sporadically.
1
/// Australian Dollar
2
final Currency aud = Currency.create('AUD', 2,
3
pattern: 'S0.00',
4
country: 'Australian',
5
unit: 'Dollar',
6
name: 'Australian Dollar');
7
8
/// Bitcoin
9
final Currency btc = Currency.create('BTC', 8,
10
symbol: '₿',
11
pattern: 'S0.00000000',
12
country: 'Digital',
13
unit: 'Bitcoin',
14
name: 'Bitcon');
15
16
/// Brazilian Real
17
final Currency brl = Currency.create('BRL', 2,
18
symbol: r'R#x27;,
19
invertSeparators: true,
20
pattern: 'S0,00',
21
country: 'Brazil',
22
unit: 'Real',
23
name: 'Brazilian Real');
24
25
/// British Pound Sterling
26
final Currency gbp = Currency.create('GBP', 2,
27
symbol: '£',
28
country: 'Britan',
29
unit: 'Pound Sterling',
30
name: 'British Pound Sterling');
31
32
/// Canadian Dollar
33
final Currency cad = Currency.create('CAD', 2,
34
country: 'Canada', unit: 'Dollar', name: 'Canadian Dollar');
35
36
/// Chinese Renminbi
37
final Currency cny = Currency.create('CNY', 2,
38
symbol: '¥',
39
country: 'China',
40
unit: 'Renminbi',
41
name: 'Chinese Renminbi');
42
43
/// Czech Koruna
44
final Currency czk = Currency.create('CZK', 2,
45
symbol: 'Kč',
46
invertSeparators: true,
47
pattern: '0,00S',
48
country: 'Czech',
49
unit: 'Koruna',
50
name: 'Czech Koruna');
51
52
/// European Union Euro
53
final Currency euro = Currency.create('EUR', 2,
54
symbol: '€',
55
invertSeparators: true,
56
pattern: '0,00S',
57
country: 'European Union',
58
unit: 'Euro',
59
name: 'European Union Euro');
60
61
/// Ghana Cedi
62
final Currency ghs = Currency.create('GHS', 2,
63
symbol: '₵',
64
pattern: 'S0.00',
65
country: 'Ghana',
66
unit: 'Cedi',
67
name: 'Ghana Cedi');
68
69
/// Indian Rupee
70
final Currency inr = Currency.create('INR', 2,
71
symbol: '₹',
72
pattern: 'S0.00',
73
country: 'Indian',
74
unit: 'Rupee',
75
name: 'Indian Rupee');
76
77
/// Japanese Yen
78
final Currency jpy = Currency.create('JPY', 0,
79
symbol: '¥',
80
pattern: 'S0',
81
country: 'Japanese',
82
unit: 'Yen',
83
name: 'Japanese Yen');
84
85
/// Mexican Peso
86
final Currency mxn = Currency.create('MXN', 2,
87
country: 'Mexican', unit: 'Peso', name: 'Mexican Peso');
88
89
/// New Zealand Dollar
90
final Currency nzd = Currency.create('NZD', 2,
91
country: 'New Zealand', unit: 'Dollar', name: 'New Zealand Dollar');
92
93
/// Nigerian Naira
94
final Currency ngn = Currency.create('NGN', 2,
95
symbol: '₦',
96
pattern: 'S0.00',
97
country: 'Nigerian',
98
unit: 'Naira',
99
name: 'Nigerian Naira');
100
101
/// Norwegian Krone
102
final Currency nok = Currency.create('NOK', 2,
103
symbol: 'kr',
104
country: 'Norwegian',
105
unit: 'Krone',
106
name: 'Norwegian Krone');
107
108
/// Polish Zloty
109
final Currency pln = Currency.create('PLN', 2,
110
symbol: 'zł',
111
invertSeparators: true,
112
pattern: '0,00S',
113
country: 'Polish',
114
unit: 'Zloty',
115
name: 'Polish Zloty');
116
117
/// South African Rand
118
final Currency zar = Currency.create('ZAR', 2,
119
symbol: 'R',
120
country: 'South African',
121
unit: 'Rand',
122
name: 'South African Rand');
123
124
/// South Korean Won
125
final Currency krw = Currency.create('KRW', 0,
126
symbol: '₩',
127
pattern: 'S0',
128
country: 'South Korean',
129
unit: 'Won',
130
name: 'South Korean Won');
131
132
/// Swiss Franc
133
final Currency chf = Currency.create('CHF', 2,
134
symbol: 'fr', country: 'Switzerland', unit: 'Franc', name: 'Swiss Franc');
135
136
/// New Taiwan Dollar
137
final Currency twd = Currency.create('TWD', 0,
138
symbol: r'NT#x27;,
139
pattern: 'S0',
140
country: 'New Taiwan',
141
unit: 'Dollar',
142
name: 'New Taiwan Dollar');
143
144
/// Turkish Lira
145
final Currency ltry = Currency.create('TRY', 2,
146
symbol: '₺', country: 'Turkish', unit: 'Lira', name: 'Turkish Lira');
147
148
/// Russian Ruble
149
final Currency rub = Currency.create('RUB', 2,
150
symbol: '₽', country: 'Russia', unit: 'Ruble', name: 'Russian Ruble');
151
152
/// United States Dollar
153
final Currency usd = Currency.create('USD', 2,
154
country: 'United States of America',
155
unit: 'Dollar',
156
name: 'United States Dollar');
Copied!
Copy link