2023-03-24 15:26:42 +00:00
|
|
|
import 'package:cw_core/currency.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/enumerable_item.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2023-03-24 15:26:42 +00:00
|
|
|
class FiatCurrency extends EnumerableItem<String> with Serializable<String> implements Currency {
|
2022-10-12 17:09:57 +00:00
|
|
|
const FiatCurrency({required String symbol, required this.countryCode, required this.fullName}) : super(title: symbol, raw: symbol);
|
2022-06-29 12:38:44 +00:00
|
|
|
|
|
|
|
final String countryCode;
|
|
|
|
final String fullName;
|
2020-01-08 12:26:34 +00:00
|
|
|
|
2020-09-23 18:26:10 +00:00
|
|
|
static List<FiatCurrency> get all => _all.values.toList();
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2022-07-01 11:04:00 +00:00
|
|
|
static List<FiatCurrency> get currenciesAvailableToBuyWith =>
|
2024-01-08 14:03:46 +00:00
|
|
|
[aud, bgn, brl, cad, chf, clp, cop, czk, dkk, egp, eur, gbp, gtq, hkd, hrk, huf, idr, ils, inr, isk, jpy, krw, mad, mxn, myr, ngn, nok, nzd, php, pkr, pln, ron, sek, sgd, thb, twd, usd, vnd, zar, tur];
|
2022-07-01 11:04:00 +00:00
|
|
|
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const ars = FiatCurrency(symbol: 'ARS', countryCode: "arg", fullName: "Argentine Peso");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const aud = FiatCurrency(symbol: 'AUD', countryCode: "aus", fullName: "Australian Dollar");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const bdt = FiatCurrency(symbol: 'BDT', countryCode: "bgd", fullName: "Bangladeshi Taka");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const bgn = FiatCurrency(symbol: 'BGN', countryCode: "bgr", fullName: "Bulgarian Lev");
|
|
|
|
static const brl = FiatCurrency(symbol: 'BRL', countryCode: "bra", fullName: "Brazilian Real");
|
|
|
|
static const cad = FiatCurrency(symbol: 'CAD', countryCode: "cad", fullName: "Canadian Dollar");
|
|
|
|
static const chf = FiatCurrency(symbol: 'CHF', countryCode: "che", fullName: "Swiss Franc");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const clp = FiatCurrency(symbol: 'CLP', countryCode: "chl", fullName: "Chilean Peso");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const cny = FiatCurrency(symbol: 'CNY', countryCode: "chn", fullName: "Chinese Yuan");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const cop = FiatCurrency(symbol: 'COP', countryCode: "col", fullName: "Colombian Peso");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const czk = FiatCurrency(symbol: 'CZK', countryCode: "czk", fullName: "Czech Koruna");
|
|
|
|
static const dkk = FiatCurrency(symbol: 'DKK', countryCode: "dnk", fullName: "Danish Krone");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const egp = FiatCurrency(symbol: 'EGP', countryCode: "egy", fullName: "Egyptian Pound");
|
|
|
|
static const eur = FiatCurrency(symbol: 'EUR', countryCode: "eur", fullName: "Euro");
|
|
|
|
static const gbp = FiatCurrency(symbol: 'GBP', countryCode: "gbr", fullName: "Pound Sterling");
|
|
|
|
static const ghs = FiatCurrency(symbol: 'GHS', countryCode: "gha", fullName: "Ghanaian Cedi");
|
|
|
|
static const gtq = FiatCurrency(symbol: 'GTQ', countryCode: "gtm", fullName: "Guatemalan Quetzal");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const hkd = FiatCurrency(symbol: 'HKD', countryCode: "hkg", fullName: "Hong Kong Dollar");
|
|
|
|
static const hrk = FiatCurrency(symbol: 'HRK', countryCode: "hrv", fullName: "Croatian Kuna");
|
|
|
|
static const huf = FiatCurrency(symbol: 'HUF', countryCode: "hun", fullName: "Hungarian Forint");
|
|
|
|
static const idr = FiatCurrency(symbol: 'IDR', countryCode: "idn", fullName: "Indonesian Rupiah");
|
|
|
|
static const ils = FiatCurrency(symbol: 'ILS', countryCode: "isr", fullName: "Israeli New Shekel");
|
|
|
|
static const inr = FiatCurrency(symbol: 'INR', countryCode: "ind", fullName: "Indian Rupee");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const irr = FiatCurrency(symbol: 'IRR', countryCode: "irn", fullName: "Iranian Rial");
|
|
|
|
static const isk = FiatCurrency(symbol: 'ISK', countryCode: "isl", fullName: "Icelandic Krona Króna");
|
|
|
|
static const jpy = FiatCurrency(symbol: 'JPY', countryCode: "jpn", fullName: "Japanese Yen");
|
|
|
|
static const krw = FiatCurrency(symbol: 'KRW', countryCode: "kor", fullName: "South Korean Won");
|
|
|
|
static const mad = FiatCurrency(symbol: 'MAD', countryCode: "mar", fullName: "Moroccan Dirham");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const mxn = FiatCurrency(symbol: 'MXN', countryCode: "mex", fullName: "Mexican Peso");
|
|
|
|
static const myr = FiatCurrency(symbol: 'MYR', countryCode: "mys", fullName: "Malaysian Ringgit");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const ngn = FiatCurrency(symbol: 'NGN', countryCode: "nga", fullName: "Nigerian Naira");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const nok = FiatCurrency(symbol: 'NOK', countryCode: "nor", fullName: "Norwegian Krone");
|
|
|
|
static const nzd = FiatCurrency(symbol: 'NZD', countryCode: "nzl", fullName: "New Zealand Dollar");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const php = FiatCurrency(symbol: 'PHP', countryCode: "phl", fullName: "Philippine Peso");
|
|
|
|
static const pkr = FiatCurrency(symbol: 'PKR', countryCode: "pak", fullName: "Pakistani Rupee");
|
|
|
|
static const pln = FiatCurrency(symbol: 'PLN', countryCode: "pol", fullName: "Poland Zloty złoty");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const ron = FiatCurrency(symbol: 'RON', countryCode: "rou", fullName: "Romanian Leu");
|
|
|
|
static const rub = FiatCurrency(symbol: 'RUB', countryCode: "rus", fullName: "Russian Ruble");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const sar = FiatCurrency(symbol: 'SAR', countryCode: "sau", fullName: "Saudi Riyal");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const sek = FiatCurrency(symbol: 'SEK', countryCode: "swe", fullName: "Swedish Krona");
|
|
|
|
static const sgd = FiatCurrency(symbol: 'SGD', countryCode: "sgp", fullName: "Singapore Dollar");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const thb = FiatCurrency(symbol: 'THB', countryCode: "tha", fullName: "New Thaiwan Dollar");
|
|
|
|
static const twd = FiatCurrency(symbol: 'TWD', countryCode: "twn", fullName: "Thai Baht");
|
|
|
|
static const uah = FiatCurrency(symbol: 'UAH', countryCode: "ukr", fullName: "Ukrainian Hryvnia");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const usd = FiatCurrency(symbol: 'USD', countryCode: "usa", fullName: "United States Dollar");
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
static const vef = FiatCurrency(symbol: 'VEF', countryCode: "ven", fullName: "Venezuelan Bolivar Bolívar");
|
|
|
|
static const vnd = FiatCurrency(symbol: 'VND', countryCode: "vnm", fullName: "Vietnamese Dong đồng");
|
2022-06-29 12:38:44 +00:00
|
|
|
static const zar = FiatCurrency(symbol: 'ZAR', countryCode: "saf", fullName: "South African Rand");
|
2024-01-08 14:03:46 +00:00
|
|
|
static const tur = FiatCurrency(symbol: 'TRY', countryCode: "tur", fullName: "Turkish Lira");
|
2020-01-04 19:31:52 +00:00
|
|
|
|
2020-09-23 18:26:10 +00:00
|
|
|
static final _all = {
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.ars.raw: FiatCurrency.ars,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.aud.raw: FiatCurrency.aud,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.bdt.raw: FiatCurrency.bdt,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.bgn.raw: FiatCurrency.bgn,
|
|
|
|
FiatCurrency.brl.raw: FiatCurrency.brl,
|
|
|
|
FiatCurrency.cad.raw: FiatCurrency.cad,
|
|
|
|
FiatCurrency.chf.raw: FiatCurrency.chf,
|
2023-02-27 18:29:05 +00:00
|
|
|
FiatCurrency.clp.raw: FiatCurrency.clp,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.cny.raw: FiatCurrency.cny,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.cop.raw: FiatCurrency.cop,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.czk.raw: FiatCurrency.czk,
|
|
|
|
FiatCurrency.dkk.raw: FiatCurrency.dkk,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.egp.raw: FiatCurrency.egp,
|
|
|
|
FiatCurrency.eur.raw: FiatCurrency.eur,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.gbp.raw: FiatCurrency.gbp,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.ghs.raw: FiatCurrency.ghs,
|
|
|
|
FiatCurrency.gtq.raw: FiatCurrency.gtq,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.hkd.raw: FiatCurrency.hkd,
|
|
|
|
FiatCurrency.hrk.raw: FiatCurrency.hrk,
|
|
|
|
FiatCurrency.huf.raw: FiatCurrency.huf,
|
|
|
|
FiatCurrency.idr.raw: FiatCurrency.idr,
|
|
|
|
FiatCurrency.ils.raw: FiatCurrency.ils,
|
|
|
|
FiatCurrency.inr.raw: FiatCurrency.inr,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.irr.raw: FiatCurrency.irr,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.isk.raw: FiatCurrency.isk,
|
|
|
|
FiatCurrency.jpy.raw: FiatCurrency.jpy,
|
|
|
|
FiatCurrency.krw.raw: FiatCurrency.krw,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.mad.raw: FiatCurrency.mad,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.mxn.raw: FiatCurrency.mxn,
|
|
|
|
FiatCurrency.myr.raw: FiatCurrency.myr,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.ngn.raw: FiatCurrency.ngn,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.nok.raw: FiatCurrency.nok,
|
|
|
|
FiatCurrency.nzd.raw: FiatCurrency.nzd,
|
|
|
|
FiatCurrency.php.raw: FiatCurrency.php,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.pkr.raw: FiatCurrency.pkr,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.pln.raw: FiatCurrency.pln,
|
|
|
|
FiatCurrency.ron.raw: FiatCurrency.ron,
|
|
|
|
FiatCurrency.rub.raw: FiatCurrency.rub,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.sar.raw: FiatCurrency.sar,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.sek.raw: FiatCurrency.sek,
|
|
|
|
FiatCurrency.sgd.raw: FiatCurrency.sgd,
|
|
|
|
FiatCurrency.thb.raw: FiatCurrency.thb,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.twd.raw: FiatCurrency.twd,
|
|
|
|
FiatCurrency.uah.raw: FiatCurrency.uah,
|
2020-09-23 18:26:10 +00:00
|
|
|
FiatCurrency.usd.raw: FiatCurrency.usd,
|
Add fiat currencies
Adds:
AED, ARS, BDT, CLP, COP, EGP, GHS, GTQ, IRR, MAD, NGN, PKR, SAR, THB, TRY, UAH, VND
This may mess things up because of TRY, so I'll test the PR and make changes as needed
2023-02-27 17:43:07 +00:00
|
|
|
FiatCurrency.vef.raw: FiatCurrency.vef,
|
|
|
|
FiatCurrency.vnd.raw: FiatCurrency.vnd,
|
2024-01-08 14:03:46 +00:00
|
|
|
FiatCurrency.zar.raw: FiatCurrency.zar,
|
|
|
|
FiatCurrency.tur.raw: FiatCurrency.tur,
|
2020-09-23 18:26:10 +00:00
|
|
|
};
|
|
|
|
|
2024-10-31 01:10:40 +00:00
|
|
|
static FiatCurrency deserialize({required String raw}) => _all[raw] ?? FiatCurrency.usd;
|
2020-09-23 18:26:10 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) => other is FiatCurrency && other.raw == raw;
|
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
@override
|
|
|
|
int get hashCode => raw.hashCode ^ title.hashCode;
|
2023-03-24 15:26:42 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
String get name => raw;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String? get tag => null;
|
|
|
|
|
|
|
|
@override
|
|
|
|
String get iconPath => "assets/images/flags/$countryCode.png";
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|