yakui
yakui copied to clipboard
Implement Intrinsic Sizing
A lesser-known part of the Flutter layout algorithm is that objects can report their intrinsic size as opposed to just computing their actual size when performing layout.
This would simplify a lot of widgets and open a lot of doors for us, like being able to implement IntrinsicSize
.
Here's some interesting code in Flutter about this: https://github.com/flutter/flutter/blob/f1875d570e39de09040c8f79aa13cc56baab8db1/packages/flutter/lib/src/rendering/box.dart#L1449
API Additions
As part of this, we'll add two new methods to Widget
:
/// Tells the intrinsic width of the object, which is its width if the
/// widget were given unbounded constraints.
fn intrinsic_width(&self) -> f32 {
0.0
}
/// Tells the intrinsic height of the object, which is its height if the
/// widget were given unbounded constraints.
fn intrinsic_height(&self) -> f32 {
0.0
}