paginate method
Pagination: If you're working with paginated data, you can create custom extensions to handle pagination-related operations.
Implementation
List<E> paginate(int page, int itemsPerPage) {
final startIndex = (page - 1) * itemsPerPage;
final endIndex = startIndex + itemsPerPage;
if (startIndex >= length) return [];
return sublist(startIndex, endIndex.clamp(0, length));
}