aagarwal1012 / Liquid-Pull-To-Refresh

🔁 A custom refresh indicator for flutter.

Home Page:https://pub.dev/packages/liquid_pull_to_refresh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ListView with ScrollController stopped working

JotaFerreira opened this issue · comments

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?

@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.

this problem also happens to the RefreshIndicator, I'll have to remove the library for now. Thanks!

flutter/flutter#22180