feat:增加消息功能
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class ImMessage {
|
||||
final String type;
|
||||
final String from;
|
||||
@@ -11,10 +13,27 @@ class ImMessage {
|
||||
required this.content,
|
||||
});
|
||||
|
||||
factory ImMessage.fromJsonString(String json) {
|
||||
return ImMessage.fromJson(jsonDecode(json));
|
||||
}
|
||||
|
||||
factory ImMessage.fromJson(Map<String, dynamic> json) {
|
||||
return ImMessage(
|
||||
type: json['type'],
|
||||
from: json['from'],
|
||||
to: json['to'],
|
||||
content: json['content'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'type': type,
|
||||
'from': from,
|
||||
'to': to,
|
||||
'content': content,
|
||||
};
|
||||
|
||||
String toJsonString() {
|
||||
return jsonEncode(toJson());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user