-
Notifications
You must be signed in to change notification settings - Fork 4
/
EthTokenModel.dart
68 lines (56 loc) · 1.34 KB
/
EthTokenModel.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// Created by dyf on 2018/9/6.
// Copyright (c) 2018 dyf.
//
/// Defines a model for the token.
class EthTokenModel {
// The address for the token.
String address;
// The name for the token.
String name;
// The balance for the token.
String balance;
// The symbol for the token.
String symbol;
// The value for the token.
String value;
// The state for the token.
bool isShown;
// Constructor
EthTokenModel({
this.address,
this.name,
this.balance,
this.symbol,
this.value,
this.isShown
});
Map<String, dynamic> toMap() {
var map = new Map<String, dynamic>();
if (address != null && address.isNotEmpty) {
map["address"] = address.toLowerCase();
}
if (name != null && name.isNotEmpty) {
map["name"] = name;
}
if (balance != null && balance.isNotEmpty) {
map["balance"] = balance;
}
if (symbol != null && symbol.isNotEmpty) {
map["symbol"] = symbol;
}
if (value != null && value.isNotEmpty) {
map["value"] = value;
}
map["isShown"] = this.isShown == true ? 1 : 0;
return map;
}
EthTokenModel.fromMap(Map<String, dynamic> map) {
address = map["address"];
name = map["name"];
balance = map["balance"];
symbol = map["symbol"];
value = map["value"];
isShown = map["isShown"] == 1;
}
}