2023-01-11 17:19:19 +00:00
|
|
|
class Crypto {
|
|
|
|
/// Crypto ticker
|
2023-01-10 21:25:20 +00:00
|
|
|
final String ticker;
|
|
|
|
|
2023-01-11 17:19:19 +00:00
|
|
|
/// Crypto name
|
2023-01-10 21:25:20 +00:00
|
|
|
final String name;
|
|
|
|
|
2023-01-20 21:30:35 +00:00
|
|
|
/// Crypto network
|
|
|
|
final String? network;
|
|
|
|
|
|
|
|
/// Crypto contract address
|
|
|
|
final String? contractAddress;
|
|
|
|
|
2023-01-11 17:19:19 +00:00
|
|
|
Crypto({
|
2023-01-10 21:25:20 +00:00
|
|
|
required this.ticker,
|
|
|
|
required this.name,
|
2023-01-20 21:30:35 +00:00
|
|
|
required this.network,
|
|
|
|
required this.contractAddress,
|
2023-01-10 21:25:20 +00:00
|
|
|
});
|
|
|
|
|
2023-01-11 17:19:19 +00:00
|
|
|
factory Crypto.fromJson(Map<String, dynamic> json) {
|
2023-01-10 21:25:20 +00:00
|
|
|
try {
|
2023-01-11 17:19:19 +00:00
|
|
|
return Crypto(
|
2023-01-20 21:45:53 +00:00
|
|
|
ticker: "${json['ticker']}",
|
|
|
|
name: "${json['name']}",
|
|
|
|
network: "${json['network']}",
|
|
|
|
contractAddress: "${json['contractAddress']}",
|
2023-01-10 21:25:20 +00:00
|
|
|
);
|
|
|
|
} catch (e) {
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
final map = {
|
|
|
|
"ticker": ticker,
|
|
|
|
"name": name,
|
2023-01-20 21:30:35 +00:00
|
|
|
"network": network,
|
|
|
|
"contractAddress": contractAddress,
|
2023-01-10 21:25:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
2023-01-11 17:19:19 +00:00
|
|
|
Crypto copyWith({
|
2023-01-10 21:25:20 +00:00
|
|
|
String? ticker,
|
|
|
|
String? name,
|
|
|
|
}) {
|
2023-01-11 17:19:19 +00:00
|
|
|
return Crypto(
|
2023-01-10 21:25:20 +00:00
|
|
|
ticker: ticker ?? this.ticker,
|
|
|
|
name: name ?? this.name,
|
2023-01-20 21:30:35 +00:00
|
|
|
network: network ?? this.network,
|
|
|
|
contractAddress: contractAddress ?? this.contractAddress,
|
2023-01-10 21:25:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2023-01-11 17:19:19 +00:00
|
|
|
return "Crypto: ${toJson()}";
|
2023-01-10 21:25:20 +00:00
|
|
|
}
|
|
|
|
}
|