I am trying to make a reels app. I am getting this error, I checked other answers for this question all of them said there is a problem with the video but I am using cloud-firestore URL, the same URL is working for the listview Widget but not for pageview. The screen becomes completely blank when I navigate to this screen.
PageViewScreen :
class _PageViewBuilderState extends State<PageViewBuilder> {
var network = '';
VideoPlayerController? videoPlayerController;
@override
void initState() {
super.initState();
videoPlayerController = VideoPlayerController.network(network)
..addListener(() {})
..setLooping(true)
..initialize().then((value) => videoPlayerController!.play());
}
int _currentPage = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream:
FirebaseFirestore.instance.collection('Imageurls').snapshots(),
builder: (ctx, snapshot) {
return !snapshot.hasData
? const Center(
child: CircularProgressIndicator(),
)
: PageView.builder(
scrollDirection: Axis.vertical,
itemCount: snapshot.data!.docs.length,
onPageChanged: (int page) {
setState(() {
_currentPage = page;
});
},
itemBuilder: (BuildContext context, int index) {
return AspectRatio(
aspectRatio: VideoPlayerController.network(
snapshot.data!.docs[index].get('url'),
).value.aspectRatio,
child: VideoPlayer(VideoPlayerController.network(
snapshot.data!.docs[index].get('url'),
)
..addListener(() {})
..setLooping(true)
..initialize()
.then((value) => VideoPlayerController.network(
snapshot.data!.docs[index].get('url'),
).play())),
);
},
);
}),
);
}
}
What I have tried:
I did try to use this same page builder for getting image from cloud at that time it was working