im_message_model.dart
1.93 KB
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
69
70
71
72
import 'dart:convert';
class ImMessageModel {
String bizType;
String version;
dynamic payload;
int fromAccount;
int toAccount;
int timestamp;
int read;
int key;
int transferAccount;
bool isShowCancel = false;
int uploadProgress;
String avatar;
String nickname;
bool isShowDate = false;
ImMessageModel(
{this.bizType,
this.key,
this.isShowDate = false,
this.uploadProgress,
this.version,
this.avatar,
this.nickname,
this.isShowCancel = false,
this.payload,
this.fromAccount,
this.toAccount,
this.timestamp,
this.read,
this.transferAccount});
ImMessageModel.fromJson(Map<String, dynamic> json) {
this.bizType = json['biz_type'];
this.version = json['version'];
this.isShowCancel = json['is_show_cancel'] ?? false;
this.payload = json['payload'];
this.key = json['key'];
this.fromAccount = json['from_account'];
this.toAccount = json['to_account'];
this.timestamp = json['timestamp'];
this.avatar = json['avatar'];
this.read = json['read'];
this.uploadProgress = json['upload_progress'] ?? 0;
this.nickname = json['nickname'];
this.transferAccount = json['transfer_account'];
}
String toBase64() {
return base64Encode(utf8.encode(json.encode(toJson())));
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['biz_type'] = this.bizType;
data['version'] = this.version;
data['key'] = this.key;
data['upload_progress'] = this.uploadProgress;
data['is_show_cancel'] = this.isShowCancel;
data['payload'] = this.payload;
data['from_account'] = this.fromAccount;
data['to_account'] = this.toAccount;
data['timestamp'] = this.timestamp;
data['avatar'] = this.avatar;
data['read'] = this.read;
data['nickname'] = this.nickname;
data['transfer_account'] = this.transferAccount;
return data;
}
}