Skip to main content

SubcomposeLayout

Function SubcomposeLayout 

Source
pub fn SubcomposeLayout<F>(modifier: Modifier, content: F) -> View
where F: Fn(SubcomposeScope) -> View + 'static,
Expand description

A layout whose content closure is invoked with the current available size (in dp) and returns one or more (slot_id, view) pairs.

The single-slot form takes a closure that returns a single View; that view is implicitly assigned slot id 0. The multi-slot form takes a closure returning a Vec<(u64, View)> and is exposed by subcompose_layout_with_slots for callers that need multiple slots.

content runs during reconcile. The first frame the closure is called and its result is cached; subsequent frames reuse the cached result as long as the available scope (and the SubcomposeLayout’s modifier) are unchanged.

If content captures state (such as a Signal) whose changes should re-trigger the closure, use subcompose_with_key (or box_with_constraints_with_key) so the cache is invalidated when that state changes.