'flutter video_player(or chewie) enter full screen on landscape mode like youtube

I need a video player that enters full screen when the device is rotated to landscape mode and back. Just like how the video player in apps like YouTube and Udemy. I am using chewie and there is an open issue about it in https://github.com/brianegan/chewie/issues/15 From that, I found this solution https://gist.github.com/ihrankouski/0a353a8de649b648b3ceff0d8e97f1d7 which has a problem that it won't come back to the normal position on portrait mode.

also, there is a file in the chewie example
https://github.com/brianegan/chewie/blob/master/example/lib/auto_rotate.dart that does this(maybe. I don't know what the code is for) but is not working when I tried. Does this have any problem? If yes then what is the problem?

Is there another library that has this functionality, If yes how can this be done with that library.



Solution 1:[1]

Regarding fullscreen you can added it as a parameter to your ChewieController

_chewieController = ChewieController(
  _videoPlayerController: videoPlayerController,
  fullScreenByDefault: true);

Regarding Orientation you can set that in the initiState()

import 'package:flutter/services.dart';

  @override
  void initState() {
    super.initState();
    initializePlayer();
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
    ]);
  }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TomD