searchMsgFromDB method Null safety
- String keywords,
- {int timeStamp = -1,
- int maxCount = 20,
- String from = '',
- EMMessageSearchDirection direction = EMMessageSearchDirection.Up}
搜索包含keywords
的消息,消息类型为type
,起始时间timeStamp
,条数maxCount
, 消息发送方from
,方向direction
。
Implementation
Future<List<EMMessage>> searchMsgFromDB(
String keywords, {
int timeStamp = -1,
int maxCount = 20,
String from = '',
EMMessageSearchDirection direction = EMMessageSearchDirection.Up,
}) async {
Map req = Map();
req['keywords'] = keywords;
req['timeStamp'] = timeStamp;
req['maxCount'] = maxCount;
req['from'] = from;
req['direction'] = direction == EMMessageSearchDirection.Up ? "up" : "down";
Map result =
await _channel.invokeMethod(EMSDKMethod.searchChatMsgFromDB, req);
EMError.hasErrorFromResult(result);
List<EMMessage> list = [];
result[EMSDKMethod.searchChatMsgFromDB]?.forEach((element) {
list.add(EMMessage.fromJson(element));
});
return list;
}