aagarwal1012 / Liquid-Pull-To-Refresh

🔁 A custom refresh indicator for flutter.
https://pub.dev/packages/liquid_pull_to_refresh
MIT License
1.25k stars 91 forks source link

ListView with ScrollController stopped working #4

Closed JotaFerreira closed 5 years ago

JotaFerreira commented 5 years ago

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 5 years ago

@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 5 years ago

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

https://github.com/flutter/flutter/issues/22180