ListView with ScrollController stopped working
JotaFerreira opened this issue · 2 comments
JotaFerreira commented
My code
LiquidPullToRefresh(
key: _refreshIndicatorKey,
onRefresh: _reload,
showChildOpacityTransition: false,
backgroundColor: Theme.of(context).accentColor,
color: Theme.of(context).primaryColor,
child: new ListView.builder(
padding: EdgeInsets.only(
bottom: 5.0, top: 5.0),
itemCount: _posts.length + 1,
itemBuilder: (context, index) {
if (this._posts.length == index) {
return _buildProgressIndicator();
} else {
return PostWidget(
post: _posts[index]);
}
},
controller: widget.scrollController,
),
)
This listener stopped working
widget.scrollController.addListener(() {
if (widget.scrollController.position.pixels ==
widget.scrollController.position.maxScrollExtent) {
_getMoreData();
}
});
Any suggestion?
aagarwal1012 commented
@JotaFerreira, Each element of list view is converted into a sliver and put into the custom scroll view widget. That's why your listener stopped listening.
List<Widget> slivers =List.from(widget.child.buildSlivers(context), growable: true);
You can rebuild the list view after the onRefresh
method is done.
JotaFerreira commented
this problem also happens to the RefreshIndicator, I'll have to remove the library for now. Thanks!