API ReferenceNavigation & Scrolling
GridView
Count, extent, and builder grids with delegate options.
use incular::prelude::*;
fn main() {
let app = Application::new(|_cx| {
Container::builder()
.padding(EdgeInsets::all(24.0))
.alignment(Alignment::CENTER)
.child(
GridView::builder(
20,
SliverGridDelegate::fixed_cross_axis_count(2)
.main_axis_spacing(8.0)
.cross_axis_spacing(8.0),
|i| Text::new(format!("cell {i}")),
),
)
.build()
.into()
})
.expect("valid application");
incular::run(app).expect("run application");
}GridView::count, GridView::extent, and
SliverGridDelegate::max_cross_axis_extent share the same shapes.
| Constructor | Layout |
| --- | --- |
| `count(n, children)` | Fixed column count |
| `extent(max, children)` | Columns from max extent |
| `builder(n, delegate, f)` | Lazy cells |
| `fixed_cross_axis_count(n)` | Delegate; count clamps `>= 1` |
| `max_cross_axis_extent(px)` | Delegate; extent-driven columns |
For lazy grids see [`SliverGrid`](/docs/api/navigation/sliver-grid).
Related: [`ListView`](/docs/api/navigation/list-view).