loadMessages method
Future<List<EMMessage> >
loadMessages({
- String startMsgId = '',
- int loadCount = 20,
- EMMessageSearchDirection direction = EMMessageSearchDirection.Up,
根据起始消息id获取消息
Implementation
Future<List<EMMessage>> loadMessages({
String startMsgId = '',
int loadCount = 20,
EMMessageSearchDirection direction = EMMessageSearchDirection.Up,
}) async {
Map req = this.toJson();
req["startId"] = startMsgId;
req['count'] = loadCount;
req['direction'] = direction == EMMessageSearchDirection.Up ? "up" : "down";
Map<String, dynamic> result = await _emConversationChannel.invokeMethod(
EMSDKMethod.loadMsgWithStartId, req);
EMError.hasErrorFromResult(result);
List<EMMessage> msgList = [];
result[EMSDKMethod.loadMsgWithStartId]?.forEach((element) {
msgList.add(EMMessage.fromJson(element));
});
return msgList;
}