getMessages static method
Future<void>
getMessages(
- int conversationType,
- String targetId,
- HistoryMessageOption option,
- dynamic finished()?,
Implementation
static Future<void> getMessages(int conversationType, String targetId, HistoryMessageOption option, Function(List? /*<Message>*/ msgList, int? code)? finished) async {
Map paramMap = {
'conversationType': conversationType,
'targetId': targetId,
"count": option.count,
"recordTime": option.recordTime,
"order": option.order,
};
Map resultMap = await _channel.invokeMethod(RCMethodKey.GetMessages, paramMap);
int? code = resultMap["code"];
if (code == 0) {
List? msgStrList = resultMap["messages"];
if (msgStrList == null) {
if (finished != null) {
finished(null, code);
}
return;
}
List l = [];
for (String msgStr in msgStrList) {
Message? m = MessageFactory.instance!.string2Message(msgStr);
l.add(m);
}
if (finished != null) {
finished(l, code);
}
} else {
if (finished != null) {
finished(null, code);
}
}
}