I've been looking everywhere I don't know what's happening but when I run this code, the scroll up is not working anymore.
Basically I have a kind of instagram feed with videos. I use this widget to display the videos. If I scroll down on the feed, it works, but as soon as I scroll up it get jerky.
class CustomVidPlayerCopy extends StatefulWidget {
CustomVidPlayerCopy({
this.width,
this.height,
required this.videoPath,
});
final double? width;
final double? height;
final String videoPath;
@override
_CustomVidPlayerState createState() => _CustomVidPlayerState();
}
class _CustomVidPlayerState extends State<CustomVidPlayerCopy> {
late VideoPlayerController _videoPlayerController;
late ChewieController _chewieController;
late Future<void> _initializeVideoPlayerFuture;
@override
void initState() {
super.initState();
_videoPlayerController = VideoPlayerController.network(widget.videoPath);
_initializeVideoPlayerFuture = _videoPlayerController.initialize();
_videoPlayerController.setVolume(0.0);
}
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _initializeVideoPlayerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
_chewieController = ChewieController(
videoPlayerController: _videoPlayerController,
aspectRatio: _videoPlayerController.value.aspectRatio,
autoInitialize: true,
looping: true,
showControls: false,
autoPlay: true,
);
return Container(
child: AspectRatio(
aspectRatio: _videoPlayerController.value.aspectRatio,
child: Stack(
children: [
// Display the video using Chewie
Chewie(
controller: _chewieController,
),
GestureDetector(
behavior: HitTestBehavior.opaque,
),
],
),
),
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
);
}
}