pub struct UnconstrainedBox;Expand description
Lets its child be its natural size even where the parent offers less — and says so when that does not fit.
The child is laid out as if nothing were constraining it, and the box is as big as the child, up to the space it was itself offered. Where the child fits, nothing is unusual — the box is simply the child’s size, hugging it in a place that would have stretched it. Where it does not, the child is painted past the edges and a band says by how much, in debug builds.
// A row of chips that must not be squashed: too many, and the overflow is visible.
UnconstrainedBox::new(Flex::row().child(chip_a).child(chip_b))That visible failure is the point, and the difference between this and OverflowBox,
which spills on purpose and quietly. It is ConstraintsTransformBox with the
constraint taken away, and nothing more.
UnconstrainedBox::axis frees one axis and leaves the other as it was, which is
usually what is wanted: a paragraph that may be as tall as it likes is still as wide as
its column.
Implementations§
Source§impl UnconstrainedBox
impl UnconstrainedBox
Sourcepub fn new<Msg: Clone + 'static>(
child: impl Widget<Msg> + 'static,
) -> ConstraintsTransformBox<Msg>
pub fn new<Msg: Clone + 'static>( child: impl Widget<Msg> + 'static, ) -> ConstraintsTransformBox<Msg>
Frees both axes.