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.
37 lines
932 B
37 lines
932 B
/// 直播间聊天消息模型
|
|
class LiveChatMessage {
|
|
final String userId;
|
|
final String userName;
|
|
final String? avatar;
|
|
final String content;
|
|
final int timestamp;
|
|
|
|
LiveChatMessage({
|
|
required this.userId,
|
|
required this.userName,
|
|
this.avatar,
|
|
required this.content,
|
|
required this.timestamp,
|
|
});
|
|
|
|
factory LiveChatMessage.fromJson(Map<String, dynamic> json) {
|
|
return LiveChatMessage(
|
|
userId: json['userId'] ?? json['uid'] ?? '',
|
|
userName: json['userName'] ?? json['nickName'] ?? '用户',
|
|
avatar: json['avatar'] ?? json['profilePhoto'],
|
|
content: json['content'] ?? json['message'] ?? '',
|
|
timestamp: json['timestamp'] ?? DateTime.now().millisecondsSinceEpoch,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'userId': userId,
|
|
'userName': userName,
|
|
'avatar': avatar,
|
|
'content': content,
|
|
'timestamp': timestamp,
|
|
};
|
|
}
|
|
}
|
|
|