feature: Add container.size property to get actual rendered dimensions
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
You can try this for now: https://docs.flet.dev/controls/container/#size-aware
Will see if we could make it better.
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.