I have built a streambuilder that has two-page builders. I realized it is not iterating over the last if statement, does anyone knows a function so that I can get it to iterate over the last if statement too?
The condition of all if statements are being met
My widget:
StreamBuilder2<QuerySnapshot<Map<String, dynamic>>,
QuerySnapshot<Map<String, dynamic>>>(
streams: Tuple2(stream1, stream2),
builder: (ctx, snapshots) {
if (!snapshots.item1.hasData && !snapshots.item2.hasData) {
return const Center(
child: CircularProgressIndicator(),
);
}
if (snapshots.item1.hasData) {
return PageView.builder(
itemCount: snapshots.item1.data!.docs.length,
itemBuilder: ((context, index) {
INvideoPlayerController = VideoPlayerController.network(
snapshots.item1.data!.docs[index].get('url'),
)
..setLooping(true)
..initialize()
.then((value) => INvideoPlayerController!.play());
return AspectRatio(
aspectRatio: INvideoPlayerController!.value.aspectRatio,
child: VideoPlayer(INvideoPlayerController!),
);
}));
}
if (snapshots.item2.hasData ) {
return PageView.builder(
itemCount: snapshots.item2.data!.docs.length,
itemBuilder: ((context, index) {
return FittedBox(
child: Container(
margin: const EdgeInsets.all(7),
child: FadeInImage.memoryNetwork(
fit: BoxFit.cover,
placeholder: kTransparentImage,
image:
snapshots.item2.data!.docs[index].get('url')),
),
);
}));
}
return Text('done');
}),
What I have tried:
I tried using one-page builder but I was getting the same problem that I was not able to exit the 2nd if loop even after the data was not present in it which gave range errors.
I cannot find a solution on the net on how to make it iterate over another loop.