I created a widget named InfiniteScroll
which handles asynchronously loaded data and renders it with ListView.builder
. However I am having trouble creating a controller for it (for example for clearing all the loaded data). I read through the implementation of existing controllers such as TextEditingController
but I can't seem to wrap my head around it. Here's an example of what I'm trying to achieve:
// I have
InfiniteScroll(
fetchMore: () async {}, // fetching more data
builder: (data) {}, // building an item
)
// need
InfiniteScroll(
controller: _infiniteScrollController,
fetchMore: () async {}, // fetching more data
builder: (data) {} // building an item
)
// later
_infiniteScrollController.clearItems();
How to create such a controller? I am using flutter_hooks
for local state management if that matters.