feat:增加消息记录功能
This commit is contained in:
13
lib/services/message_store.dart
Normal file
13
lib/services/message_store.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:sweet_chat_app/models/im_message.dart';
|
||||
|
||||
class MessageStore {
|
||||
static final Map<String, List<ImMessage>> _data = {};
|
||||
|
||||
static void add(ImMessage msg) {
|
||||
_data.putIfAbsent(msg.to, () => []).add(msg);
|
||||
_data.putIfAbsent(msg.from, () => []).add(msg);
|
||||
}
|
||||
|
||||
static List<ImMessage> messagesFor(String userId) =>
|
||||
_data[userId] ?? [];
|
||||
}
|
||||
Reference in New Issue
Block a user