I have a TabBar which has 19 items, swiping trough them works fine and works as intended.
Issue I have is when the controller.index
jumps from more than 1 index, like this:
I also noticed that when I set the controller.index
where index is more than 1, the http request is called 3 times.
I/flutter (18372): https://www.subotica.info/restful-najava-za-danas?page=0
I/flutter (18372): https://www.subotica.info/restful-latest?page=0 // the category i clicked on
I/flutter (18372): https://www.subotica.info/restful-najava-za-danas?page=0
So first time it calls on the controller.index + 1
then the one I actually selected and once again on controller.index + 1
Setting it inside a drawer:
ListTile(
title: Text(NewsConstant.latestNews),
onTap: () {
setState(() {
controller.index = 0;
Navigator.of(context).pop();
});
}),
I found out that I have to iterate it one by one
ListTile(
title: Text(NewsConstant.cultureNews),
onTap: () {
setState(() {
pageNumber = 0;
for(int i=controller.index; i<3 ;i ++)
controller.index++;
Navigator.of(context).pop();
isFresh = api.isFresh();
});
}),
Just have to make a function for every category
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.