flutter yoyo player controller
345
I found a solution.
widgetsBinding.addPostFrameCallback((callback) {
widgetsBinding.addPersistentFrameCallback((callback) {
if (context == null) return;
Becomes:
widgetsBinding.addPostFrameCallback((callback) {
widgetsBinding.addPersistentFrameCallback((callback) {
if (!mounted) return;
Line 151 in video.dart.
Author by
Humayun Kabir
Updated on December 28, 2022Comments
-
Humayun Kabir over 1 year
I am using yoyo_player to play live stream video. When I back/pop to the home page, I am getting the following exception:
This widget has been unmounted, so the State no longer has a context (and should be considered defunct)
I can't dispose of yoyo player because it has no controller. Following is my code:
YoYoPlayer( aspectRatio: 16 / 9, url: "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8", //"https://stream.mux.com/pYcUEtxsvAyEQBydYkR7dCnBVenRMt7JyuvVno6Y40000.m3u8", videoStyle: VideoStyle( play : Icon(Icons.play_arrow), pause : Icon(Icons.pause), fullscreen : Icon(Icons.fullscreen), ), videoLoadingStyle: VideoLoadingStyle( loading: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ CircularProgressIndicator(), Text("Loading video"), ], ), ), ), onfullscreen: (t) { if(mounted){ removeBannerAd(); setState(() { fullscreen = t; }); } }, )
How to resolve this exception?
-
Vedant Rathore about 3 yearsDid you happen to find a solution to this problem? I'm facing the same
-
Humayun Kabir about 3 years@VedantRathore I didn't find any solution so far
-