Jumping at the start and end
Closed this issue · 1 comments
chrisDK1977 commented
Hi,
I like the plugin and have a suggestion for improvement.
if you have 20 entries, the bar increases at the beginning and at the end - there are not always the same amount of elements and that is then strange when clicking through.
The following small change would change that (the hardcoded numbers must be made conifgurable if necessary).
List<Widget> _buildPageItemList() {
List<Widget> widgetList = [];
widgetList.add(_PageControlButton(
enable: currentPage > 1,
title: '«',
onTap: () {
_updatePage(currentPage - 1);
},
));
int _page = max(1, currentPage - max(5, (10 - (totalPage-currentPage)))); // HERE
for (; _page <= currentPage; _page++) {
widgetList.add(_PageItem(
page: _page,
isChecked: _page == currentPage,
onTap: (page) {
_updatePage(page);
},
));
}
int endPage = min(totalPage, max(_page + 4, 11)); // HERE
for (; _page <= endPage; _page++) {
widgetList.add(_PageItem(
page: _page,
isChecked: _page == currentPage,
onTap: (page) {
_updatePage(page);
},
));
}
widgetList.add(_PageControlButton(
enable: currentPage < totalPage,
title: '»',
onTap: () {
_updatePage(currentPage + 1);
},
));
return widgetList;
}
Many greetings
Christian
lazyee commented
Thanks for your feedback, now I have changed the code according to your suggestion, now you can try flutter_web_pagination: ^0.0.3