openFullScreen method
Opens the video in full screen.
For some reason, we need to re-initialize the video when the full screen dialog is dismissed. So we save the state obtained by showDialog and re-initialize controller to match.
Implementation
Future<void> openFullScreen() async {
controller.isFullScreen = true;
final plugin.VideoPlayerValue video = await showDialog(
context: context,
builder: (_) => WillPopScope(
onWillPop: closeFullScreen,
child: Scaffold(body: Center(child: VideoPlayer(controller)))
)
);
controller.isFullScreen = false;
// BUG: We shouldn't have to re-initialize every time!
await controller.initialize();
await controller.seekTo(video.position);
if (video.isPlaying) await controller.play();
setState(() {});
}