@@ -11,11 +11,11 @@ void main() {
11
11
/// Create money from Fixed amount
12
12
13
13
final fixed = Fixed .fromInt (100 );
14
- Money .parse ('1.23' , code : 'AUD' );
14
+ Money .parse ('1.23' , isoCode : 'AUD' );
15
15
16
- Money .fromFixed (fixed, code : 'AUD' );
16
+ Money .fromFixed (fixed, isoCode : 'AUD' );
17
17
18
- Money .fromDecimal (Decimal .parse ('1.23' ), code : 'EUR' );
18
+ Money .fromDecimal (Decimal .parse ('1.23' ), isoCode : 'EUR' );
19
19
20
20
///
21
21
/// Create a money which stores $USD 10.00
@@ -24,7 +24,7 @@ void main() {
24
24
/// monetary value.
25
25
/// So $10.00 is 1000 cents.
26
26
///
27
- final costPrice = Money .fromInt (1000 , code : 'USD' );
27
+ final costPrice = Money .fromInt (1000 , isoCode : 'USD' );
28
28
29
29
print (costPrice);
30
30
// > $10.00
@@ -42,13 +42,13 @@ void main() {
42
42
/// Create a [Money] instance from a String
43
43
/// using [Money.parse]
44
44
///
45
- final taxPrice = Money .parse (r'$1.50' , code : 'USD' );
45
+ final taxPrice = Money .parse (r'$1.50' , isoCode : 'USD' );
46
46
print (taxPrice.format ('CC 0.0 S' ));
47
47
// > US 1.50 $
48
48
49
49
///
50
50
/// Create a [Money] instance from a String
51
- /// with an embedded Currency Code
51
+ /// with an embedded Currency isoCode
52
52
/// using [Currencies.parse]
53
53
///
54
54
/// Create a custom currency
@@ -68,7 +68,7 @@ void main() {
68
68
Currencies ().register (Currency .create ('DODGE' , 5 , symbol: 'Ð' ));
69
69
final dodge = Currencies ().find ('DODGE' );
70
70
Money .fromNumWithCurrency (0.1123 , dodge! );
71
- Money .fromNum (0.1123 , code : 'DODGE' );
71
+ Money .fromNum (0.1123 , isoCode : 'DODGE' );
72
72
73
73
///
74
74
/// Do some maths
@@ -84,7 +84,7 @@ void main() {
84
84
///
85
85
/// Do some custom formatting of the ouput
86
86
/// S - the symbol e.g. $
87
- /// CC - first two digits of the currency code provided when creating
87
+ /// CC - first two digits of the currency isoCode provided when creating
88
88
/// the currency.
89
89
/// # - a digit if required
90
90
/// 0 - a digit or the zero character as padding.
@@ -95,7 +95,7 @@ void main() {
95
95
/// Explicitly define the symbol and the default pattern to be used
96
96
/// when calling [Money.toString()]
97
97
///
98
- /// JPY - code for japenese yen.
98
+ /// JPY - isoCode for japenese yen.
99
99
/// 0 - the number of minor units (e.g cents) used by the currency.
100
100
/// The yen has no minor units.
101
101
/// ¥ - currency symbol for the yen
@@ -118,7 +118,10 @@ void main() {
118
118
/// -> 1.000,00
119
119
///
120
120
final euro = Currency .create ('EUR' , 2 ,
121
- symbol: '€' , invertSeparators: true , pattern: '#.##0,00 S' );
121
+ symbol: '€' ,
122
+ groupSeparator: '.' ,
123
+ decimalSeparator: ',' ,
124
+ pattern: '#,##0.00 S' );
122
125
123
126
final bmwPrice = Money .fromIntWithCurrency (10025090 , euro);
124
127
print (bmwPrice);
@@ -130,7 +133,7 @@ void main() {
130
133
///
131
134
132
135
// 100,345.30 usd
133
- final teslaPrice = Money .fromInt (10034530 , code : 'USD' );
136
+ final teslaPrice = Money .fromInt (10034530 , isoCode : 'USD' );
134
137
135
138
print (teslaPrice.format ('###,###' ));
136
139
// > 100,345
@@ -142,14 +145,14 @@ void main() {
142
145
// > US100,345.30
143
146
144
147
// 100,345.30 EUR
145
- final euroCostPrice = Money .fromInt (10034530 , code : 'EUR' );
146
- print (euroCostPrice.format ('###. ###' ));
148
+ final euroCostPrice = Money .fromInt (10034530 , isoCode : 'EUR' );
149
+ print (euroCostPrice.format ('###, ###' ));
147
150
// > 100.345
148
151
149
- print (euroCostPrice.format ('###. ###, ## S' ));
152
+ print (euroCostPrice.format ('###, ###. ## S' ));
150
153
// > 100.345,3 €
151
154
152
- print (euroCostPrice.format ('###. ###, #0 CC' ));
155
+ print (euroCostPrice.format ('###, ###. #0 CC' ));
153
156
// > 100.345,30 EU
154
157
155
158
///
@@ -161,7 +164,7 @@ void main() {
161
164
Currencies ().register (jpy);
162
165
163
166
// use a registered currency by finding it in the registry using
164
- // the currency code that the currency was created with.
167
+ // the currency isoCode that the currency was created with.
165
168
final usDollar = Currencies ().find ('USD' );
166
169
167
170
final invoicePrice = Money .fromIntWithCurrency (1000 , usDollar! );
@@ -180,7 +183,7 @@ void main() {
180
183
181
184
// retrieve all registered currencies
182
185
final registeredCurrencies = Currencies ().getRegistered ();
183
- final codes = registeredCurrencies.map ((c) => c.code );
186
+ final codes = registeredCurrencies.map ((c) => c.isoCode );
184
187
print (codes);
185
188
// (USD, AUD, EUR, JPY)
186
189
}
0 commit comments