Widgets

GridView

GridView

Display repeated content in a tiled layout.

Example

grid_view(
  runs_count: 2,
  spacing: 8,
  run_spacing: 8,
  children: [
    text(value: "A"),
    text(value: "B"),
    text(value: "C"),
    text(value: "D")
  ]
)

Common properties

  • runs_count
  • children
  • spacing
  • run_spacing
  • expand

Usage

grid_view(
  runs_count: 3,
  spacing: 12,
  children: items.map { |item| text(value: item[:name]) }
)

Notes

  • Use children: for the tiles, consistent with column, row, and

list_view.

Complete API

Helpers

  • grid_view(children = ..., **props, &block)
  • gridview(children = ..., **props, &block)

Accepted properties

  • adaptive — Adapts to the platform (Material/Cupertino) when true.
  • align — Alignment of the control within its parent.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • aspect_ratio — Width-to-height ratio to maintain.
  • auto_scroll — Sets the auto scroll property.
  • badge — Badge drawn on the corner of the control.
  • bottom — Bottom offset when positioned inside a stack.
  • build_controls_on_demand — Sets the build controls on demand property.
  • cache_extent — Sets the cache extent property.
  • child_aspect_ratio — Sets the child aspect ratio property.
  • clip_behavior — How content overflowing the bounds is clipped.
  • col — Responsive column span (1-12) per breakpoint.
  • controls — The list of child controls.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • height — Fixed height in logical pixels.
  • horizontal — Sets the horizontal property.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around the control.
  • max_extent — Sets the max extent property.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • padding — Inner spacing between the border and the content.
  • reverse — Sets the reverse property.
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • rtl — Renders right-to-left when true.
  • run_spacing — Sets the run spacing property.
  • runs_count — Sets the runs count property.
  • scale — Scale transform applied to the control.
  • scroll — Sets the scroll property.
  • scroll_interval — Sets the scroll interval property.
  • semantic_child_count — Sets the semantic child count property.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • spacing — Sets the spacing property.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_scroll — Fired when the scroll position changes.
  • on_size_change — Fired when the control's size changes.

Wire reference

  • Family: shared
  • Widget type: gridview