Files
sweet_chat_app/lib/models/ImMessage.dart
2026-06-18 14:20:37 +08:00

39 lines
729 B
Dart

import 'dart:convert';
class ImMessage {
final String type;
final String from;
final String to;
final String content;
ImMessage({
required this.type,
required this.from,
required this.to,
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());
}
}