Incular logoIncular
API ReferenceLayout Widgets

PreferredSize

Report a preferred size to parents like app bars.

PreferredSize { preferred_size: Size, child: Widget } reports a fixed preferred size to layout parents (e.g. AppBar.bottom slots) while laying out its child normally.

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(
                PreferredSize::new(
                    Size::new(0.0, 48.0),
                    Text::new("Preferred height"),
                ),
            )
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

Related: SizedBox, AppBar.