Component - Infinite scrolling
This UI component shows a list that loads more items automatically when you scroll to the bottom. It feels like the list never ends because new items keep appearing as you scroll down.
This UI component shows a list that loads more items automatically when you scroll to the bottom. It feels like the list never ends because new items keep appearing as you scroll down.
Scaffold ├─ AppBar └─ ListView.builder ├─ ListTile (item 0) ├─ ListTile (item 1) ├─ ... └─ CircularProgressIndicator (loading more)
ScrollController _controller = ScrollController();
_controller.addListener(() {
if (_controller.position.pixels == _controller.position.maxScrollExtent) {
print('Load more items');
}
});ScrollController _controller = ScrollController();
@override
void initState() {
super.initState();
_controller.addListener(() {
if (_controller.position.pixels >= _controller.position.maxScrollExtent) {
fetchMoreData();
}
});
}
@override
void dispose() {
super.dispose();
}Pass the test and this pattern moves unknown