onScrollChanged method
Implementation
@override
bool onScrollChanged(ScrollNotification scrollInfo) {
super.onScrollChanged(scrollInfo);
final loadPageRequestState = viewModel.loadPageRequestState;
bool canLoad;
if (loadPageRequestState == null) {
canLoad = false;
} else {
final isSucceed = loadPageRequestState.isSucceed;
final isIdle = loadPageRequestState.isIdle;
final isAllItemsNotLoaded = !viewModel.isAllItemsLoaded;
canLoad = (isSucceed || isIdle) && isAllItemsNotLoaded;
}
final currentPixelsPosition = scrollInfo.metrics.pixels;
final maxScrollExtent = scrollInfo.metrics.maxScrollExtent;
final isCurrentPixelsPositionEnd = currentPixelsPosition == maxScrollExtent;
if (isCurrentPixelsPositionEnd && canLoad) {
viewModel.loadPage!();
return true;
}
return false;
}