Home > Software engineering >  Flutter: How to get the size of a child widget in an overlay before it is rendered to use it in its
Flutter: How to get the size of a child widget in an overlay before it is rendered to use it in its

Time:04-22

TL;DR

I have a parent that depends on the size of a child and that child is in the overlay and is not rendered until the parent is pressed, how can I get the child's size before rendering to layout the parent correctly?

Details

I edited flutter's PopupMenuButton and created a enter image description here

I need to know the size of the content (the blue row) in order to place it above the child (the Text widget above) like here (where the offset is hardcoded): enter image description here

The problem is that content is not actually rendered until I press on the Text so using GlobalKey in the code above will not work because when the code above executes the conten is still not actually rendered and Size returned by the global key will be zero or null.

Also, using enter image description here

  • Related