Incular logoIncular
API ReferenceLayout Widgets

ConstrainedBox

Impose additional layout constraints on a child.

ConstrainedBox { constraints, child } — both required, no defaults.

Props

Prop

Type

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                ConstrainedBox::new(
                    Constraints::tight(Size::new(160.0, 64.0)),
                    Text::new("Exactly 160x64"),
                ),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Methods

pub fn new(constraints: Constraints, child: impl Into<Widget>) -> Self

See Constraints for tight, loose, unbounded, deflate, and loosen.

Related: LimitedBox, OverflowBox, SizedBox.

On this page