aagarwal1012/Liquid-Pull-To-Refresh

Not working with ListView.builder

kamami opened this issue · 3 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.