loadMessagesWithKeyword method
Future<List<EMMessage> >
loadMessagesWithKeyword(
- String keywords, {
- String? sender,
- int timestamp = -1,
- int count = 20,
- EMMessageSearchDirection direction = EMMessageSearchDirection.Up,
Implementation
Future<List<EMMessage>> loadMessagesWithKeyword(
String keywords, {
String? sender,
int timestamp = -1,
int count = 20,
EMMessageSearchDirection direction = EMMessageSearchDirection.Up,
}) async {
Map req = this.toJson();
req["keywords"] = keywords;
req['count'] = count;
if (sender != null) {
req['sender'] = sender;
}
req['timestamp'] = timestamp;
req['direction'] = direction == EMMessageSearchDirection.Up ? "up" : "down";
Map<String, dynamic> result = await _emConversationChannel.invokeMethod(
EMSDKMethod.loadMsgWithKeywords, req);
EMError.hasErrorFromResult(result);
List<EMMessage> msgList = [];
result[EMSDKMethod.loadMsgWithKeywords]?.forEach((element) {
msgList.add(EMMessage.fromJson(element));
});
return msgList;
}