dev
dart 41 lines 1017 Bytes
Raw
1 import 'package:cw_core/amount/money.dart';
2 import 'package:cw_core/currency.dart';
3
4 class FiatCurrency implements Currency {
5 const FiatCurrency({
6 required this.symbol,
7 required this.countryCode,
8 required this.fullName,
9 this.decimals = 2,
10 });
11
12 final String countryCode;
13
14 @override
15 final String fullName;
16
17 @override
18 final int decimals;
19
20 @override
21 final String symbol;
22
23 @override
24 String? get iconPath => throw UnimplementedError();
25
26 @override
27 String get name => throw UnimplementedError();
28
29 @override
30 String? get tag => throw UnimplementedError();
31
32 @override
33 Money parseAmount(String value) => Money.parse(value, this);
34
35 @override
36 Money? tryParseAmount(String value) => Money.tryParse(value, this);
37 }
38
39 const EUR = FiatCurrency(symbol: 'EUR', countryCode: "eur", fullName: "Euro");
40 const USD = FiatCurrency(symbol: 'USD', countryCode: "usd", fullName: "US Dollar");
41 const JPY = FiatCurrency(symbol: 'JPY', countryCode: "jpn", fullName: "Japanese Yen", decimals: 0);