getHistoryMessages method

Future<List> getHistoryMessages ({@required dynamic type, @required int from, @required int limit, bool isDescend: false })

Implementation

Future<List> getHistoryMessages({
  @required dynamic type, /// (JMSingle | JMGroup)
  @required int from,
  @required int limit,
  bool isDescend = false
}) async {
  Map param = type.toJson();

  param..addAll({
    'from': from,
    'limit': limit,
    'isDescend': isDescend
    });

  List resArr = await _channel.invokeMethod('getHistoryMessages',
    param..removeWhere((key,value) => value == null));

  List res = [];
  for (Map messageMap in resArr) {
    dynamic d = JMNormalMessage.generateMessageFromJson(messageMap);
    if (d != null) {
      res.add(d);
    }else{
      print("get history msg, get a message is null");
    }
  }
  //var res = resArr.map((messageMap) => JMNormalMessage.generateMessageFromJson(messageMap)).toList();
  return res;
}