flet icon indicating copy to clipboard operation
flet copied to clipboard

feature: Add container.size property to get actual rendered dimensions

Open malikmajai opened this issue 10 months ago • 2 comments

Duplicate Check

  • [x] I have searched the opened issues and there are no duplicates

Describe the requested feature

Currently, there's no straightforward way to get the actual rendered dimensions of a Container or other controls after they've been laid out. The width and height properties only return values if they were explicitly set, returning None otherwise.

When building dynamic layouts, it's often necessary to know the actual space a control occupies after rendering - similar to how PIL/Pillow's textbbox() returns the actual bounding box of text.

Suggest a solution

Add a .size property (or .get_size() method) to Container and other controls that returns the actual rendered dimensions:

Screenshots

No response

Additional details

No response

malikmajai avatar Jan 28 '26 06:01 malikmajai

You can try this for now: https://docs.flet.dev/controls/container/#size-aware

Will see if we could make it better.

ndonkoHenri avatar Jan 28 '26 19:01 ndonkoHenri

Wouldn’t the performance overhead of real-time monitoring be significant? If there are too many controls, it would be a disaster. Is it possible to retrieve the dimensions on demand when needed, similar to .size? This would greatly reduce performance costs. Furthermore, size change monitoring itself could be implemented by wrapping the control with a Canvas widget.

Qye-Leisure avatar Feb 27 '26 13:02 Qye-Leisure