Skip to main content
The Stac GridView allows you to build a Flutter GridView widget using JSON. To know more about the GridView widget in Flutter, refer to the official documentation.

Properties

PropertyTypeDescription
scrollDirectionStacAxisThe axis along which the grid scrolls. Defaults to Axis.vertical.
reverseboolWhether the grid scrolls in the reverse direction. Defaults to false.
primaryboolWhether this is the primary scroll view. Defaults to false.
physicsStacScrollPhysicsThe physics for the scroll view.
shrinkWrapboolWhether the extent of the scroll view in the scrollDirection should be determined by the contents being viewed. Defaults to false.
paddingStacEdgeInsetsThe amount of space by which to inset the grid.
crossAxisCountintThe number of children in the cross axis.
mainAxisSpacingdoubleThe amount of space between the children in the main axis. Defaults to 0.0.
crossAxisSpacingdoubleThe amount of space between the children in the cross axis. Defaults to 0.0.
childAspectRatiodoubleThe ratio of the cross-axis to the main-axis extent of each child. Defaults to 1.0.
mainAxisExtentdoubleThe extent of each child in the main axis.
addAutomaticKeepAlivesboolWhether to add automatic keep-alives. Defaults to true.
addRepaintBoundariesboolWhether to add repaint boundaries. Defaults to true.
addSemanticIndexesboolWhether to add semantic indexes. Defaults to true.
cacheExtentdoubleThe extent to which the content is cached.
childrenList<StacWidget>The widgets below this widget in the tree. Defaults to an empty list.
semanticChildCountintThe number of children for semantics purposes.
dragStartBehaviorStacDragStartBehaviorThe drag start behavior. Defaults to DragStartBehavior.start.
keyboardDismissBehaviorStacScrollViewKeyboardDismissBehaviorThe keyboard dismiss behavior. Defaults to ScrollViewKeyboardDismissBehavior.manual.
restorationIdStringThe restoration ID to save and restore the scroll offset.
clipBehaviorStacClipThe clip behavior of the grid. Defaults to Clip.hardEdge.

Example

StacGridView(
  scrollDirection: StacAxis.vertical,
  reverse: false,
  primary: false,
  physics: StacScrollPhysics(name: 'bouncing'),
  shrinkWrap: false,
  padding: StacEdgeInsets(left: 10, top: 10, right: 10, bottom: 10),
  crossAxisCount: 2,
  mainAxisSpacing: 10.0,
  crossAxisSpacing: 10.0,
  childAspectRatio: 1.0,
  mainAxisExtent: 100.0,
  addAutomaticKeepAlives: true,
  addRepaintBoundaries: true,
  addSemanticIndexes: true,
  cacheExtent: 100.0,
  children: [
    StacText(data: 'Item 1'),
    StacText(data: 'Item 2'),
  ],
  semanticChildCount: 2,
  dragStartBehavior: StacDragStartBehavior.start,
  keyboardDismissBehavior: StacScrollViewKeyboardDismissBehavior.manual,
  restorationId: 'grid_view_1',
  clipBehavior: StacClip.hardEdge,
)