getSubList method

List<Map<String, dynamic>> getSubList(
  1. int offset,
  2. int limit,
  3. List<Map<String, dynamic>>? tempList
)

Implementation

List<Map<String, dynamic>> getSubList(
    int offset, int limit, List<Map<String, dynamic>>? tempList) {
  List<Map<String, dynamic>> subList = [];
  if (tempList == null) return subList;
  if (offset == -1) {
    subList = tempList;
  } else if (limit > 0 && limit + offset < tempList.length) {
    subList = tempList.sublist(offset, limit + offset);
  } else if (offset < tempList.length) {
    subList = tempList.sublist(offset);
  } else {
    subList = tempList;
  }
  return subList;
}