I’m working on a multimedia feed application similar to Instagram and running into a persistent challenge with video playback. I’ve used various packages like chewie_player (with riverpod) and awesome_player (with GetX), but I’m struggling with performance and memory management.
My main issue is with the sheer number of VideoPlayerController instances. When scrolling through a feed with many videos (like stories or a main feed), the constant initialization and disposal of controllers seems to cause significant memory issues, leading to a less-than-smooth user experience. I’ve tried caching controllers and other optimization methods, but the performance is still far from ideal, especially compared to native apps.
Is this a known limitation or a common challenge in Flutter? I’m looking for a better way to handle state and memory for a feed with numerous video components. What are the best practices or architectural patterns for building a highly performant and memory-efficient video-heavy application in Flutter?
Any insights, from state management strategies to specific package recommendations for this use case, would be greatly appreciated.
We created our own Vidoplayer based on the Android and iOS players to manage the number of active players and caching videos. It can be tricky. Make sure to dispose players that you don’t display always.
And stay away from getX.
We also use a custom video player (based off official video_player package) with a custom feed framework that handles feed of videos (creation and disposing), playing of videos and rendering overlays. We also track controllers across the app and make sure we only have set number initialized at all times.
Size of the video and caching is also very important.
getX isn’t recommended for any type of bigger apps because imit makes very easy to write code that will be hard to extend and maintain after some time.
Use get_it/watch_it, provider, riverpod or bloc
For what it’s worth, we also built customizations on top of the video_player plugin. Where we got the most performance was in our custom caching framework and ensuring a strict number of live controllers at any one point. We also make heavy use of riverpod for state management. This is all high level and may not be useful for you, but I wanted to encourage you that it’s possible to build the kind of app you’re trying to build in Flutter. In case you want to see how our video scrolling experience feels like (across Android and iOS), you can check out the Groovetime app on the app store. It’s pretty smooth.
Using contents of this forum for the purposes of training proprietary AI models is forbidden. Only if your AI model is free & open source, go ahead and scrape. Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.