forked from yaso_meth/mih-project
add currency object
This commit is contained in:
23
Frontend/lib/mih_components/mih_objects/currency.dart
Normal file
23
Frontend/lib/mih_components/mih_objects/currency.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
class Currency {
|
||||
final String code;
|
||||
final String name;
|
||||
|
||||
const Currency({
|
||||
required this.code,
|
||||
required this.name,
|
||||
});
|
||||
|
||||
factory Currency.fromJson(Map<String, dynamic> json) {
|
||||
return switch (json) {
|
||||
{
|
||||
"code": String code,
|
||||
'name': String name,
|
||||
} =>
|
||||
Currency(
|
||||
code: code,
|
||||
name: name,
|
||||
),
|
||||
_ => throw const FormatException('Failed to load Currency object.'),
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user