I have flutter solution, I’m working in pagination in my listView…
When existing list is equal to totalRecords I call refreshController.loadNoData() to stop paginating.
Unfortunatly, in my case listLength is equal to 10 anf totalRecords is 23 but this comparision is returning true and my pagination is not wokring because this error in comparision.
Did have have something ?
if (10 == 23)
should return false in my case but it is returning true.
int listLength = requestList.value.data!.length;
int totalRecords = value.totalRecords!;
if (listLength == totalRecords) {
refresherController.loadNoData();
}
2
Answers
Try printing the values first, then check if they’re the same:
Normally, these should be different, because there is no way that it returns true otherwise.
I changed the equality
comparison (==)
to a greater than or equal tocomparison (>=)
. This change will ensure thatrefresherController.loadNoData()
is called when thelistLength is equal to or greater than totalRecords
. By using >=, the pagination will stop when the length of the list exceeds or matches the total number of records.