0

We have a gridview.builder showing thumbnails which on tap lead to videos in a gridview. We have a streamcontroller that should trigger as you hit the bottom of the page, load a block (12 thumbnails a time). We wanted to make The whole page scroll. But now the streamcontroller doesn't trigger. If I remove the Neverscrollable physics from the gridview.builder it will trigger.

So in short, I want to be able to scroll the entire page, profile information and then through the ever loading video thumbnails. I am stuck as to why this isn't working. How do I make the streamcontroller trigger with the entire page able to scroll? Help appreciated.

SingleChildScrollView(
    controller: _scroller,
    physics: ScrollPhysics(),
    child: Container(
      height: MediaQuery.of(context).size.height,
      child: StreamBuilder<List<Post>>(
          stream: _streamController,
          builder: (context, snapshot) {
            return Column(
              children: <Widget>[
                _buildProfileInfo(_profileUser),
                Divider(),
                Flexible(
                        child: GridView.builder(
                          controller: _scrollController,
                          shrinkWrap: true,
                          physics: NeverScrollableScrollPhysics(),
                          gridDelegate:
                              SliverGridDelegateWithFixedCrossAxisCount(
                            crossAxisCount: 3,
                            childAspectRatio: 1.0,
                            mainAxisSpacing: 2.0,
                            crossAxisSpacing: 2.0,
                          ),
                          itemCount: _posts.length + 1,
                          itemBuilder: (BuildContext context, int index) {
                            if (index == _posts.length) {
                              if (!_hasMorePosts) {
                                return SizedBox.shrink();
                              } else {
                                return Center(
                                    child: Container(
                                  child: SpinKitThreeBounce(
                                    color: HexColor(hexColorMmRed),
                                    size: 30,
                                  ),
                                ));
                              }
                            } else {
                              Post post = _posts[index];
                              return _buildTilePost(post);
                            }
                          },
                        ),
                      )
              ],
            );
          }),
    ),
  );
nerdMonkey
  • 107
  • 1
  • 14

1 Answers1

0
Container(
    height: MediaQuery.of(context).size.height,
    child: StreamBuilder<List<Post>>(
        stream: _streamController,
        builder: (context, snapshot) {
          return SingleChildScrollView(
            controller: _scroller,
            child: Column(
              children: <Widget>[
                _buildProfileInfo(_profileUser),
                Divider(),
                GridView.builder(
                  shrinkWrap: true,
                  primary: false,
                  gridDelegate:
                      SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 3,
                    childAspectRatio: 1.0,
                    mainAxisSpacing: 2.0,
                    crossAxisSpacing: 2.0,
                  ),
                  itemCount: _posts.length + 1,
                  itemBuilder: (BuildContext context, int index) {
                    if (index == _posts.length) {
                      if (!_hasMorePosts) {
                        return SizedBox.shrink();
                      } else {
                        return Center(
                            child: Container(
                          child: SpinKitThreeBounce(
                            color: HexColor(hexColorMmRed),
                            size: 30,
                          ),
                        ));
                      }
                    } else {
                      Post post = _posts[index];
                      return _buildTilePost(post);
                    }
                  },
                )
              ],
            ),
          );
        }),
  );

Answer found here

nerdMonkey
  • 107
  • 1
  • 14