onScroll method
Implementation
void onScroll(ScrollMetrics metrics){
final newAtBottom = metrics.pixels >= metrics.maxScrollExtent && !metrics.outOfRange;
final newAtTop = metrics.pixels <= metrics.minScrollExtent && metrics.outOfRange;
if(widget.shaderType != null && widget.shaderType != NUIShaderMaskType.NONE && (newAtBottom != atBottom || newAtTop != atTop)) {
//Scroll position changed
atBottom = newAtBottom;
atTop = newAtTop;
bool shouldFadeTop = false;
bool shouldFadeBottom = false;
if (widget.shaderType == NUIShaderMaskType.TOP_BOTTOM_FADE) {
shouldFadeTop = !atTop;
shouldFadeBottom = !atBottom;
}
else if (widget.shaderType == NUIShaderMaskType.BOTTOM_FADE) {
shouldFadeBottom = !atBottom;
}
else if (widget.shaderType == NUIShaderMaskType.TOP_FADE) {
shouldFadeTop = !atTop;
}
if (shouldFadeTop && shouldFadeBottom)
toUseShade = NUIShaderMaskType.TOP_BOTTOM_FADE;
else if (shouldFadeTop)
toUseShade = NUIShaderMaskType.TOP_FADE;
else if (shouldFadeBottom)
toUseShade = NUIShaderMaskType.BOTTOM_FADE;
else
toUseShade = NUIShaderMaskType.NONE;
updateNUIState(id: instanceId, update: items);
}
if ((metrics.maxScrollExtent - (widget.paginateMargin ?? 0)) <= metrics.pixels) {
onPaginationLoad(isFirst: false, cursor: curModel.cursor);
}
additionalScrollListener(metrics);
if(widget.scrollListener != null){
widget.scrollListener!(metrics.pixels, atTop, atBottom);
}
}