pub struct ListView {
pub show_scrollbar: bool,
pub scrollbar_color: Color,
/* private fields */
}Expand description
A virtualized vertical list (RecyclerView / FlatList model).
Rows are built ON DEMAND by the builder closure — for a 1,000-item list
only the rows intersecting the viewport are built, laid out, and painted
each frame (typically 10–20). Memory and paint cost are O(visible), not
O(count).
v1 uses a fixed item_extent (like Flutter’s itemExtent /
RecyclerView’s fixed row height): the scroll geometry is pure arithmetic,
no measurement of off-screen rows ever happens. Variable-extent rows are
a future extension.
Prefer this over super::ScrollView for long lists — ScrollView’s
GPU-composited layer path (D090) composites its ENTIRE content as one
texture, capped at super::MAX_TL_DIM (4096 logical px); content past
that silently falls back to a plain (still correct, non-GPU) paint.
ListView never materializes off-screen content at all, so it has no
such limit regardless of count.
let scroll = ctx.state(0.0f32);
ListView::builder(1_000, 48.0, scroll, |i| {
Box::new(ListTile::new(format!("Row {i}")))
})Fields§
§show_scrollbar: bool§scrollbar_color: ColorImplementations§
Trait Implementations§
Source§impl Widget for ListView
impl Widget for ListView
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read more