setTotalPages method
Calculates the total number of pages from the given item count.
This also updates the totalPages field and returns the new paginator.
Implementation
PaginatorModel setTotalPages(int items) {
if (items < 1) return this;
var n = items ~/ perPage;
if (items % perPage > 0) n++;
return copyWith(totalPages: n);
}