stack_wallet/lib/models/buy/response_objects/fiat.dart

52 lines
897 B
Dart
Raw Normal View History

2023-01-11 17:49:59 +00:00
class Fiat {
/// Fiat ticker
final String ticker;
/// Fiat name
final String name;
/// Fiat logo url
final String image;
Fiat({required this.ticker, required this.name, required this.image});
2023-01-11 17:49:59 +00:00
factory Fiat.fromJson(Map<String, dynamic> json) {
try {
return Fiat(
ticker: json["ticker"] as String,
name: json["name"] as String,
image: json["image"] as String,
);
} catch (e) {
rethrow;
}
}
Map<String, dynamic> toJson() {
final map = {
"ticker": ticker,
"name": name,
"image": image,
};
return map;
}
Fiat copyWith({
String? ticker,
String? name,
String? image,
}) {
return Fiat(
ticker: ticker ?? this.ticker,
name: name ?? this.name,
image: image ?? this.image,
);
}
@override
String toString() {
return "Fiat: ${toJson()}";
}
}