paging<T> static method

List<T> paging<T>(
  1. List<T> list,
  2. int page,
  3. int limit
)

分页page 1 开始

Implementation

static List<T> paging<T>(List<T> list, int page, int limit) {
  List<T> listSort = [];
  int size = list.length;
  int pageStart = page == 1 ? 0 : (page - 1) * limit;//截取的开始位置
  int pageEnd = math.min(size, page * limit);//截取的结束位置
  if (size > pageStart) listSort = list.sublist(pageStart, pageEnd);
  return listSort;
}