Play video in fullscreen

Flutter tips Published on

Have you ever wanted to show a video in your Flutter app that takes up the whole screen beautifully? It's a common task, but getting the aspect ratio right so the video doesn't look stretched or squashed can be tricky. Here's a simple way to do it.

Getting Started

First, you need to add the video_player package to your project. This package handles playing videos in Flutter.

Showing the Video Fullscreen

To make the video fill the screen, you'll typically use a widget structure that ensures the video player takes all available space. Think about placing the video player inside a Stack and using Positioned.fill to make it expand.

Also, if you have an app bar but want the video to go behind it for a true fullscreen look, remember to set extendBodyBehindAppBar to true on your Scaffold.

Keeping the Right Aspect Ratio

Just making the video fill the screen isn't enough. You need to make sure it keeps its original shape (aspect ratio). A good way to handle this is by wrapping your video player widget inside a custom widget. This custom widget can use FittedBox with BoxFit.cover to scale the video while maintaining its aspect ratio, making sure it covers the entire screen area without distortion.

Inside this custom widget, you can use an AspectRatio widget to enforce the correct ratio, getting the ratio directly from the video player's value.

This approach ensures that no matter the screen size or orientation, your video will fill the screen correctly while looking exactly as it should.

Putting it Together

By combining the video_player package, setting up your layout to allow fullscreen content (like using Stack and Positioned.fill), and using a wrapper widget with FittedBox and AspectRatio to handle scaling and ratio, you can easily achieve a great fullscreen video experience in your Flutter app.

Save 3 months of work

Create your app using our 6 years of making Flutter apps and more than 50+ apps

kickstarter for flutter apps

Frequently Asked Questions

What package do I need to play videos in Flutter?

You need the `video_player` package.

How do I make the video go behind the app bar for fullscreen?

Set `extendBodyBehindAppBar: true` on your `Scaffold` widget.

How do I keep the video's aspect ratio while it's fullscreen?

You can wrap the video player in a widget that uses `FittedBox` with `BoxFit.cover` and `AspectRatio`, using the video's actual ratio.

Read more
You may also be interested in
Listen to window size changes  blog card image
Listen to window size changes
Published on 2025-05-12T11:05:44.842Z
Listen to window size changes  blog card image
Listen to window size changes
Published on 2025-05-12T11:05:44.842Z
ApparenceKit is a flutter template generator tool by Apparence.io © 2025.
All rights reserved