Show an overlay

Flutter tips Published on

What is an Overlay?

An overlay in Flutter lets you show something that floats on top of your regular page content. Think of things like pop-ups, tooltips, or loading indicators that appear over everything else.

Why use Overlays?

They are useful when you need to display information or controls that aren't part of the standard page flow and need to be visible above everything else.

Where do Overlays work?

To use Overlay.of, your app needs to be inside a MaterialApp or have a Navigator higher up in the widget tree. This gives Flutter a place to show the overlay.

How to Show an Overlay

Here's a simple way to put something like a widget on top of your screen:

  1. First, you create an OverlayEntry. This entry holds the widget you want to show.
    OverlayEntry overlayEntry = OverlayEntry(
      opaque: false, // set to true if it covers the whole screen below it
      builder: (context) => Container(...), // Put the widget you want to show here
    );
  2. Then, you find the Overlay for the current screen using Overlay.of(context).
    final overlay = Overlay.of(context);
  3. Finally, you insert your OverlayEntry into the Overlay.
    if (overlay != null) {
      overlay.insert(overlayEntry);
    }

This will place your Container(...) (or whatever widget you used) on top of your app's content.

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 is an overlay in Flutter?

An overlay allows you to show widgets or content that appear on top of all other widgets on a screen, like pop-ups or floating elements.

Where can I use Overlay.of?

You can use Overlay.of within a context that is a descendant of a MaterialApp or a Navigator.

How do I show something above my page?

You can show something above your page by creating an OverlayEntry with your desired widget and inserting it into the Overlay using Overlay.of(context).insert(overlayEntry).

What is OverlayEntry?

An OverlayEntry is an item that can be inserted into an Overlay. It contains the widget you want to display over the other content.

Read more
You may also be interested in
Flutter tips: how to create a responsive layout  blog card image
Flutter tips: how to create a responsive layout
Published on 2025-05-03
Go Beyond Material: Add Custom Colors in your Flutter Theme  blog card image
Go Beyond Material: Add Custom Colors in your Flutter Theme
Published on 2025-05-12T08:49:42.146Z
ApparenceKit is a flutter template generator tool by Apparence.io © 2025.
All rights reserved