In flutter how to use GetX to get and set first frame in video player?

Viewed 26

I am using video_player with GetX. And as you can see in official example, to get and set first frame of video as thumbnail, you have to use empty setState.

@override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
        'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized,
        // even before the play button has been pressed.
        setState(() {});
      });
  }

Now I am not able to understand even that how to figure out below code using GetX. (i.e. how do I get first frame using GetX and set it on video player as thumbnail.)

// Ensure the first frame is shown after the video is initialized, // even before the play button has been pressed. setState(() {});

Any help is much appreciated.

Edit: I am using GetX hence I do not want to use stateful widget. So how can i achieve the same example using GetX, especially what this part is doing - setState(() {});

1 Answers

actually the comment is pretty clear

Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.

the purpose of the empty setState executed after video initialize is to rebuild ui once. so first frame of your video shown in the ui.

Related