Flutter: Video Player make app like instagram listview

Viewed 447

I want to make an app like instagram in which response came from api which have images and videos but the issue is video player only play 1 video not a list of videos or each index of multiple videos so i dont know how to set it i tries it but could not work.

VideoPlayerController? _videoController;
late Future<void> _initializeVideoPlayerFuture;

   void initState(){
         super.initstate();
      initialized();
} 
   
  void initialized(){ var result = await request.getCommunity(context, token!);
setState(() {
  data = result;// result came from api in form of images and video and initialize the 
                  videocontroller
 
_videoController=VideoPlayerController.network('https://wasisoft.com/dev/${data[1['media']}');
   _initializeVideoPlayerFuture= _videoController!.initialize()..then((_) {
      setState(() {
        _videoController!.play();
      });
    });
  
});

after that inside listview.builder set a futurebuilder to set video player here it is...

  FutureBuilder(
       future: _initializeVideoPlayerFuture,
       builder: (context, snapshot) {
      if (snapshot.connectionState == ConnectionState.done) {
          return AspectRatio(
                       aspectRatio:  _videoController!.value.aspectRatio,
                             child: VideoPlayer(_videoController!),
                                    );
                       } else {
                            return  Center(child: CircularProgressIndicator(),);
                                      }
                                    },
                                  )

kindly any suggestion about this issue guide me i tried all solution related to it but could not found any helpful answer to resolve this issue.

0 Answers
Related