SGridView class

A grid-like, scrollable widget that lays out arbitrary child widgets in rows (or columns when horizontal) with a configurable number of items per cross-axis. The widget provides optional index-based auto-scrolling and simple visual scroll indicators.

Typical usage:

SGridView(
  crossAxisItemCount: 3,
  children: myTiles,
  controller: myController,
)
Inheritance
Available extensions

Constructors

SGridView({Key? key, int crossAxisItemCount = 2, required List<Widget> children, Axis mainAxisDirection = Axis.vertical, EdgeInsetsGeometry itemPadding = EdgeInsets.zero, IndexedScrollController? controller, bool showScrollIndicators = true, Color? indicatorColor, int? autoScrollToIndex, int initialIndicatorJump = 2, double indicatorScrollFraction = 1.0, Widget? emptyStateWidget})
Creates a SGridView.
const

Properties

autoScrollToIndex → int?
Optional index to auto-scroll to when the widget first builds. The value will be clamped to the valid child range; the widget computes the corresponding row and instructs the inner list to scroll to that row.
final
children → List<Widget>
The list of widgets displayed by the grid. Widgets are placed in order and split into rows/columns according to crossAxisItemCount. This list must not be null.
final
controller → IndexedScrollController?
External controller used for programmatic index-based scrolling. If not provided, SGridView will create and manage a controller internally.
final
crossAxisItemCount → int
Number of children to place on the cross axis (columns for a vertical layout, rows for a horizontal layout). Must be greater than zero.
final
emptyStateWidget → Widget?
Widget to display when children is empty. If null, an empty SizedBox is shown.
final
hashCode → int
The hash code for this object.
no setterinherited
indicatorColor → Color?
Color used for the gradient and icon of the scroll indicators. If null a sensible default (yellow) will be used.
final
indicatorScrollFraction → double
Controls the scroll distance when indicators are pressed, as a fraction of the viewport dimension. For example:
final
initialIndicatorJump → int
When pressing the forward indicator at the initial position (index 0), or the backward indicator at the final position, the grid will jump by this many groups (rows/columns) instead of the standard single-step increment. This creates a more intuitive initial navigation experience. Defaults to 2.
final
itemPadding → EdgeInsetsGeometry
Padding to apply around each child element.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
mainAxisDirection → Axis
The main scroll direction of the grid. Defaults to Axis.vertical. If set to Axis.horizontal the grid will scroll horizontally and the small visual indicators will appear on the left/right edges.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showScrollIndicators → bool
Whether to show the simple top/bottom (or left/right for horizontal) scroll indicators. Defaults to true.
final

Methods

addMaterialWidget() → Material

Available on Widget, provided by the GenericExtensions extension

addTooltipWidget(String toolTip) → Tooltip

Available on Widget, provided by the GenericExtensions extension

borderRadius([BorderRadiusGeometry? borderRadius]) → Widget

Available on Widget, provided by the GenericExtensions extension

boxDecoration([BoxDecoration? boxDecoration]) → Widget

Available on Widget, provided by the GenericExtensions extension

colorFilter([ColorFilter? colorFilter]) → Widget

Available on Widget, provided by the GenericExtensions extension

set parent widget in center
createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<SGridView>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited