You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.3 KiB
66 lines
1.3 KiB
|
|
class Message { |
|
int id; |
|
|
|
String fromId; |
|
|
|
String toId; |
|
|
|
String replyId; |
|
|
|
String content; |
|
|
|
String attach; |
|
|
|
int msgType; |
|
|
|
String time; |
|
|
|
/// 0 unread, 1 read, 2 |
|
int state; |
|
|
|
int isDelete; |
|
|
|
bool showTime = false; |
|
|
|
Message(this.id, this.fromId, this.toId, this.replyId, this.content, this.attach, this.msgType, this.time, this.state, this.isDelete); |
|
|
|
factory Message.fromJson(Map<String, dynamic> json) => Message( |
|
json["id"], |
|
json["fromId"], |
|
json["toId"], |
|
json["replyId"], |
|
json["content"], |
|
json["attach"], |
|
json["msgType"], |
|
json["time"], |
|
json["state"], |
|
json["isDelete"]); |
|
|
|
Map<String, dynamic> toJson() => <String, dynamic>{ |
|
"id": id, |
|
"fromId": fromId, |
|
"toId": toId, |
|
"replyId": replyId, |
|
"content": content, |
|
"attach": attach, |
|
"msgType": msgType, |
|
"time": time, |
|
"state": state, |
|
"isDelete": isDelete == null ? 0 : isDelete |
|
}; |
|
} |
|
|
|
createMessage(var toId, String content, {String attach, int msgType, userId, replyId}) { |
|
return <String, dynamic>{ |
|
"fromId": userId, |
|
"toId": toId, |
|
"replyId": replyId, |
|
"content": content, |
|
"attach": attach, |
|
"msgType": msgType ?? 1, |
|
"time": "${DateTime.now().millisecondsSinceEpoch}", |
|
"state": 0, |
|
"isDelete": 0 |
|
}; |
|
}
|
|
|