What is the diffrent between OverlayEntry and Stack widget in flutter?

1.7k Views Asked by At

I want to show an floating notification widget on the entire widgets of the application (on the top of MaterialApp widget). So i find two possible way to do that :

  1. wrap MaterialApp widget with a Stack widget
  2. insert my widget as OverlayEntry (Overlay.of(context).insert(MyNotificationOverlay()))

So i'm confused to choice best option to improve performance of the app for this requirement(showing notificatioin as floating widget entire the app (for example i want to show upload progress with this notification))

Thanks for your help

3

There are 3 best solutions below

0
Ash Khachatryan On

OverlayEntry creates in top of widgets. but after finish using you will remove it. If you can write your code by Stack use Stack widget.

0
Vinay Jain On

Overlay is an kind of dynamic stack. Whenever you want to show some widgets at some specific time (like it would be in an stack) we use overlay. Else when we are sure to have some things in form of stack already, we use stack.

1
Ahmed Jihad On

The overlayentry use custom stack but the broblem with overlayEntry it rebuild it self when you use some widget outside it like Pupop menu button and when writing text form feild .