Skip to main content

virtual_list

Function virtual_list 

Source
pub fn virtual_list<R>(
    id: impl Into<ElementId>,
    count: usize,
    row_height: Pixels,
    handle: &UniformListScrollHandle,
    render: impl 'static + Fn(Range<usize>, &mut Window, &mut App) -> Vec<R>,
) -> UniformList
where R: IntoElement,
Expand description

A list that builds only the rows on screen.

render is handed the visible range and returns one element per index in it; each comes back sized to row_height, which is what keeps the list uniform and therefore virtualizable at all.

Fills its parent, which is the other thing that has to be true for any of this to work: a list with no height of its own collapses, and a collapsed list builds a single row to measure and then nothing — an empty box, no error, no clue. A virtualized list is bounded by definition, so filling is the only sane default; a caller wanting otherwise sets its own size after, and the later call wins.