So my pageLoadController is calls on a function that fetches data from my backend services, page wise. This controller is defined in the initState like this
void initState() {
super.initState();
_pageLoadController = PagewiseLoadController(
pageSize: 10,
pageFuture: (pageIndex) {
return getDetails(pageIndex, 10);
});
}
My PagewiseListView widget is called inside a ListView, and the ListView is inside the Scaffold's body.
ListView(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text("Details",
style: TextStyle(
fontFamily: 'FuturaLT',
color: Theme.of(context).primaryColor,
fontSize: SizeConfig.safeBlockHorizontal * 5,
fontWeight: FontWeight.w400,
fontStyle: FontStyle.normal,
)),
PagewiseListView(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, entry, index) {
return _itemBuider(entry, SizeConfig.safeBlockVertical * 17);
},
pageLoadController: _pageLoadController,
)
where _itemBuilder returns the widget and displays the data in Entry. Now, I have worked with pagewiseListViews in the past, so the expected behavior is that when the end of the list is reached (via scrolling), the pageLoad automatically handles the network call to fetch the next data, etc.
Code for getDetails(), just a generic outline for it, rest assured data here is being fetched properly
Future<List<Details>> getDetails(
int localListSize, int localListStart) async {
var responseJson = await new NetworkUtils().netWorkcall(localListSize,localListStart);
if (responseJson != null) {
List<Details> list ;
//map data to Details model
return list;
}
return Future.value();
}
In this case, the pageController continues to make network calls, even when I have not scrolled at all, let alone reaching the end. This makes the application quite slow. Is there something I'm missing, or is this a library issue? Never had this issue in previous projects I've worked on. The version im using is
flutter_pagewise: ^1.2.3
I've upgraded to the latest version of this package too, still no luck. What am I missing?
I recently had a similar issue (in version 2.0.1), which I solved by making the
pageSizebigger.I think it is a bug of
pagewiseListViewthat happens when the page doesn't fill the given space or fills it too little; however, I have not tried to test that hypothesis.By the way, when calling your
getDetailsfunction, you give the parameterlocalListSizethe valuepageIndexandlocalListStartthe value 10 (which seems to be your page size), maybe those two are inverted?