Prechádzať zdrojové kódy

remove _onPlay listener from the controller when the widget is disposed and avoid disposing resource that I'm not the owenr of it (#27)

zshema 7 rokov pred
rodič
commit
5bd3f2c54c

+ 0 - 6
lib/src/chewie_player.dart

@@ -146,12 +146,6 @@ class _ChewiePlayerState extends State<Chewie> {
     }
   }
 
-  @override
-  void dispose() {
-    _controller.dispose();
-    super.dispose();
-  }
-
   Future<dynamic> _pushFullScreenWidget(BuildContext context) async {
     final isAndroid = Theme.of(context).platform == TargetPlatform.android;
     final TransitionRoute<Null> route = new PageRouteBuilder<Null>(

+ 6 - 0
lib/src/player_with_controls.dart

@@ -126,6 +126,12 @@ class _VideoPlayerWithControlsState extends State<PlayerWithControls> {
     }
   }
 
+  @override
+  dispose(){
+    widget.controller.removeListener(_onPlay);
+    super.dispose();
+  }
+
   void _onPlay() {
     if (widget.controller.value.isPlaying) {
       setState(() {