Skip to content

Instantly share code, notes, and snippets.

@mubasshir
Created February 27, 2020 12:23
Show Gist options
  • Save mubasshir/6f3981dfa0c186cb9dcf2fac4c8622ef to your computer and use it in GitHub Desktop.
Save mubasshir/6f3981dfa0c186cb9dcf2fac4c8622ef to your computer and use it in GitHub Desktop.
Dart Array Pagination
void main() {
List arr = [];
for (int i = 0; i < 100; i++) {
arr.add(i.toString());
}
int page = 1;
var startIndex = -1, endIndex = -1;
while (arr.length > 0 && endIndex != (arr.length - 1)) {
startIndex = (page - 1) * 10;
endIndex = (page) * 10 - 1;
print({page, startIndex, endIndex, arr.sublist(startIndex, endIndex + 1)});
page++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment