fluttercommunity / chewie

The video player for Flutter with a heart of gold
MIT License
1.95k stars 1.01k forks source link

VideoPlayerController width null #418

Open PedroSimoes opened 3 years ago

PedroSimoes commented 3 years ago

When I try to enter on fullscreen this error appear:

E/flutter (17597): Tried calling: width
E/flutter (17597): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter (17597): #1      ChewieState.onEnterFullScreen (package:chewie/src/chewie_player.dart:152:75)
E/flutter (17597): #2      ChewieState._pushFullScreenWidget (package:chewie/src/chewie_player.dart:131:5)
E/flutter (17597): #3      ChewieState.listener (package:chewie/src/chewie_player.dart:64:13)
E/flutter (17597): #4      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:226:25)
E/flutter (17597): #5      ChewieController.toggleFullScreen (package:chewie/src/chewie_player.dart:386:5)
E/flutter (17597): #6      _InCarCameraVideoWidgetState.build.<anonymous closure>.<anonymous closure> (package:flutter_app/video.dart:75:33)
E/flutter (17597): #7      State.setState (package:flutter/src/widgets/framework.dart:1244:30)
E/flutter (17597): #8      _InCarCameraVideoWidgetState.build.<anonymous closure> (package:flutter_app/video.dart:73:13)
E/flutter (17597): #9      _InCarCameraVideoWidgetState.build.<anonymous closure> (package:flutter_app/video.dart:72:22)
E/flutter (17597): #10     _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
E/flutter (17597): #11     _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
E/flutter (17597): #12     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (17597): #13     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (17597): #14     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (17597): #15     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7)
E/flutter (17597): #16     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9)
E/flutter (17597): #17     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
E/flutter (17597): #18     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (17597): #19     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (17597): #20     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (17597): #21     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (17597): #22     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19)
E/flutter (17597): #23     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
E/flutter (17597): #24     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
E/flutter (17597): #25     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7)
E/flutter (17597): #26     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
E/flutter (17597): #27     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
E/flutter (17597): #28     _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (17597): #29     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (17597): #30     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (17597): #31     _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (17597): #32     _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
E/flutter (17597): 

This is only happening on the version 0.10.0 and upper. Here is the initialization of the ChewieController:

@override
  void initState() {
    super.initState();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.landscapeRight,
    ]);
    _videoController?.dispose();
    _videoController = VideoPlayerController.file(widget.videoFile)
      ..initialize().then((_) {
        setState(() {});
      });

    _chewieController?.dispose();
    _chewieController = ChewieController(
      videoPlayerController: _videoController,
      customControls: _customControls,
      aspectRatio: _defaultAspectRatio,
      autoPlay: false,
      looping: true,
      showControlsOnInitialize: false,
      deviceOrientationsAfterFullScreen: const [DeviceOrientation.portraitUp],
    );
  }

This a know issue or it's something that i've done wrong?

PedroSimoes commented 3 years ago

After some investigation, this is only happening when you are making widget testing.