StacSliverGrid class

A Stac model representing Flutter's SliverGrid widget.

Displays its children in a two-dimensional scrollable grid within a sliver context.

This widget must be placed inside a CustomScrollView

{@tool snippet} Dart Example:

const StacSliverGrid(
  crossAxisCount: 2,
  mainAxisSpacing: 12,
  crossAxisSpacing: 12,
  childAspectRatio: 1.0,
  children: [
    StacContainer(color: '#FF5722'),
    StacContainer(color: '#4CAF50'),
  ],
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "type": "sliverGrid",
  "crossAxisCount": 2,
  "mainAxisSpacing": 16,
  "crossAxisSpacing": 16,
  "childAspectRatio": 1,
  "children": [
    {
      "type": "container",
      "color": "#4CAF50",
      "child": {
        "type": "center",
        "child": {
          "type": "text",
          "data": "Grid Item 1",
          "style": {
            "color": "#FFFFFF",
            "fontWeight": "bold"
          }
        }
      }
    },
    {
      "type": "container",
      "color": "#4CAF50",
      "child": {
        "type": "center",
        "child": {
          "type": "text",
          "data": "Grid Item 2",
          "style": {
            "color": "#FFFFFF",
            "fontWeight": "bold"
          }
        }
      }
    }
  ]
}

{@end-tool}

See also:

Inheritance
Available extensions
Annotations
  • @JsonSerializable.new()

Constructors

StacSliverGrid({int? crossAxisCount, double? mainAxisSpacing, double? crossAxisSpacing, double? childAspectRatio, double? mainAxisExtent, bool? addAutomaticKeepAlives, bool? addRepaintBoundaries, bool? addSemanticIndexes, List<StacWidget>? children})
Creates a StacSliverGrid with the given properties.
const
StacSliverGrid.fromJson(Map<String, dynamic> json)
Creates a StacSliverGrid from a JSON map.
factory

Properties

addAutomaticKeepAlives → bool?
Whether to add automatic keep-alives for the children.
final
addRepaintBoundaries → bool?
Whether to wrap children in repaint boundaries.
final
addSemanticIndexes → bool?
Whether to add semantic indexes for the children.
final
childAspectRatio → double?
The ratio of the cross-axis to the main-axis extent of each child.
final
children → List<StacWidget>?
The widgets below this sliver in the tree.
final
crossAxisCount → int?
The number of children in the cross axis.
final
crossAxisSpacing → double?
The amount of space between children in the cross axis.
final
hashCode → int
The hash code for this object.
no setterinherited
jsonData → Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
mainAxisExtent → double?
The extent of each child in the main axis.
final
mainAxisSpacing → double?
The amount of space between children in the main axis.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
type → String
Widget type identifier used by the Stac parser system.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(BuildContext context) → Widget?

Available on StacWidget?, provided by the StacWidgetParser extension

parsePreferredSizeWidget(BuildContext context) → PreferredSizeWidget?

Available on StacWidget?, provided by the StacWidgetParser extension

toJson() → Map<String, dynamic>
Converts this StacSliverGrid instance to a JSON map.
override
toString() → String
A string representation of this object.
inherited

Operators

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