widgetBuilt method
Implementation
void widgetBuilt(Duration d) {
double initPos = widget.inverted
? 0.0
: scrollController.position.maxScrollExtent + 25.0;
scrollController
.animateTo(
initPos,
duration: const Duration(milliseconds: 150),
curve: Curves.easeInOut,
)
.whenComplete(() {
_timer = Timer(Duration(milliseconds: 1000), () {
if (this.mounted) {
setState(() {
_initialLoad = false;
});
}
});
});
scrollController.addListener(() {
bool topReached = widget.inverted
? scrollController.offset >=
scrollController.position.maxScrollExtent &&
!scrollController.position.outOfRange
: scrollController.offset <=
scrollController.position.minScrollExtent &&
!scrollController.position.outOfRange;
if (widget.shouldShowLoadEarlier) {
if (topReached) {
setState(() {
showLoadMore = true;
});
} else {
setState(() {
showLoadMore = false;
});
}
} else if (topReached) {
widget.onLoadEarlier!();
}
});
}