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

Not working with ListView.builder

kamami opened this issue · comments

I am trying to implement LiquidPullToRefresh as follows:

 LiquidPullToRefresh(
        onRefresh: _refresh,	                         // refresh callback
        child: postImagesWidget(),		// scroll view
      )

But I get following error in the console:

'FutureBuilderDocumentSnapshot>>' is not a subtype of type 'ScrollView'

The "normal" RefreshIndicator is working fine with the same code.

Here is my postImagesWidget:

             Widget postImagesWidget() {
             return FutureBuilder(
             future: _future,
             builder: ((context, AsyncSnapshot<List<DocumentSnapshot>> snapshot) {
             if (snapshot.hasData) {
             if (snapshot.connectionState == ConnectionState.done) {

            return ListView.builder(
              //shrinkWrap: true,
                itemCount: snapshot.data.length,
                itemBuilder: ((context, index) =>

                      SinglePost(
                      list: snapshot.data,
                      index: index,
                      followingUser: followingUser,
                        currentUser: currentUser,

                    )));
          } else {
            return Center(
              child: CircularProgressIndicator(),
            );
          }
        } else {
          return Center(
            child: CircularProgressIndicator(),
          );
        }
      }),
    );
    }

postImagesWidget() is a FutureBuilder, but LiquidPullToRefresh's child: needs to be a ScrollView. Maybe have the FutureBuilder return a LiquidPullToRefresh that directly wraps your ListViewBuilder when you have data and returns the CircularProgressIndicator otherwise?

@Taormina works perfectly fine!

Thanks, @Taormina for solving this issue.
Now, I am closing this issue. Feel free to reopen if any problems arise.