feat:增加消息功能

This commit is contained in:
2026-06-18 14:20:37 +08:00
parent b816cdbc1c
commit bb1160ad18
7 changed files with 76 additions and 53 deletions

View File

@@ -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());
}
}