Expand description
ListView — a virtualized, scrollable list backed by a reactive data model.
ListView<T> materializes widget subtrees only for the rows currently
visible in its viewport (plus a configurable buffer). Scrolling and model
changes trigger a localized rebuild that touches only the newly-visible
slice, leaving the rest of the tree untouched. The data source is a
ListModel<T> (in-memory, reactive) or any ListDataSource<Item = T>
(lazy / external). A delegate closure (index, &T, selected) -> Box<dyn Widget>
produces each row widget on demand.
Row heights come in three modes: uniform (item_height, the 32 dp
default and fastest path), exact callback (item_height_fn — pure,
deterministic per-row sizes), and auto-measured (auto_item_height —
height-for-width measurement with scroll anchoring so content above the
viewport stays put while estimates converge).
§When to use
- Large or dynamically-loaded lists (thousands of rows) — use
ListView. - Small, always-all-visible collections — use
Repeaterinstead. - Hierarchical data — use
TreeView. - Multi-column tabular data — use
TableView.
§Accessibility
The widget is Role::List; each row is wrapped in Role::ListItem with
set_selected state. Full keyboard navigation: arrows, Home, End, PageUp,
PageDown, Space (select/toggle), Enter (activate), Ctrl+A (select all),
Shift+Arrow (range), type-ahead (opt-in via type_ahead_label).
let _w = ListView::new(model, |_i, item, _selected| {
Box::new(TextWidget::new(lit!(&item.name)))
})
.item_height(32.0)
.selection(sel);Structs§
- List
View - A virtualized scrollable list backed by a
ListModel<T>orListDataSource.