title: Flutter Streambuilder use twice in gridview builder and pageview
body: <p>I have got a gridview which contains thumbnails for videos. Now this list of thumbnails is generated from a stream. What I need is, when user taps on any of the image the particular video should get opened in a pageview. I have already achieved this but then the video opened in the pageview does not listen to any changes.</p>
  <p>I am not sure if I can use the same stream in the gridview as well as in the pageview.</p>
  <p>Here's some of my code :</p>
  <pre><code>    StreamBuilder(
                              stream: Firestore.instance
                                  .collection(&quot;videos&quot;)
                                  .where(&quot;userKey&quot;, isEqualTo: userKey)
                                  .where(&quot;isActive&quot;, isEqualTo: true)
                                  .snapshots(),
                              builder:
                                  (context, AsyncSnapshot&lt;QuerySnapshot&gt; snapshot) {
                                if (snapshot.hasData) {
                                  videos = snapshot.data.documents
                                      .map((doc) =&gt;
                                          Video.fromMap(doc.data, doc.documentID))
                                      .toList();
                                  return videos != null &amp;&amp; videos.length &gt; 0
                                      ? Stack(
                                          children: &lt;Widget&gt;[
                                            GridView.builder(
                                              gridDelegate:
                                                  SliverGridDelegateWithFixedCrossAxisCount(
                                                      childAspectRatio:
                                                          MediaQuery.of(context)
                                                                  .size
                                                                  .width /
                                                              (MediaQuery.of(context)
                                                                      .size
                                                                      .height /
                                                                  1.4),
                                                      crossAxisCount: 3),
                                              itemCount: videos.length,
      //                                    padding: EdgeInsets.all(8.0),
                                              itemBuilder:
                                                  (BuildContext context, int index) {
                                                return Padding(
                                                    padding:
                                                        const EdgeInsets.all(1.0),
                                                    child: GestureDetector(
                                                      onLongPress: () {
                                                        Get.defaultDialog(
                                                            title: &quot;Delete Video ?&quot;,
                                                            onConfirm: () async {
                                                              await DeleteVideo(
                                                                  videos[index].id);
                                                              Get.back();
                                                            },
                                                            textConfirm: &quot;Yes&quot;,
                                                            textCancel: &quot;No&quot;,
                                                            confirmTextColor:
                                                                Colors.white,
                                                            cancelTextColor:
                                                                Colors.black,
                                                            buttonColor: Colors.red
                                                                .withOpacity(0.7),
                                                            backgroundColor:
                                                                Colors.white,
                                                            middleText:
                                                                &quot;Do you want to delete this video ?&quot;);
                                                      },
                                                      onTap: () {
  _pageController =
                                                        PageController(
                                                            initialPage: index);
                                                    currentlyPlayingVideoKey =
                                                        videos[index].id;
                                                    Get.dialog(
                                                        setupAlertDialoadContainer());
  
  // opens a complete new window for each video
                                                        //Get.to(ProfileSingleVideo(
                                                            //videoKey:
                                                                //videos[index].id,
                                                            //goBackForMusic: true));
                                                      },
  
  
  
    Widget setupAlertDialoadContainer(String page) {
      showModalBottomSheet(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.vertical(top: Radius.circular(25.0)),
          ),
          context: context,
          isScrollControlled: true,
          builder: (context) =&gt; Container(
                child: new PageView.builder(
                    controller: _pageController,
                    itemCount: videos.length,
                    scrollDirection: Axis.vertical,
                    pageSnapping: true,
                    reverse: false,
                    onPageChanged: (page) {
                      setState(() {
                        currentlyPlayingVideoKey = videos[page].id;
                      });
                    },
                    itemBuilder: (context, position) {
                      return pageViewContent(video: videos[position]);
                    }),
              ));
    }
  }
  </code></pre>
  <p>Again, I am able to open the videos in the pageview and jump to the video that I want to on tap. But, the video does not listen to the changes that i make when video gets opened in the pageview. E.g. liking that video does not increement its counter although liking does work in other screens where pageview is placed directly inside of the Streambuilder. I dont want to place pageview inside the streambuider in this case though.</p>
  <p>Screenshot below to imagine it better.</p>
  <p><a href="https://i.stack.imgur.com/ET8Vr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ET8Vr.jpg" alt="enter image description here" /></a></p>