GridView constructor

GridView({
  1. required ScrollViewProperties properties,
  2. Key? key,
  3. ScrollPhysics? physics,
  4. bool shrinkWrap = false,
  5. EdgeInsetsGeometry? padding,
  6. required SliverGridDelegate gridDelegate,
  7. bool addAutomaticKeepAlives = true,
  8. bool addRepaintBoundaries = true,
  9. bool addSemanticIndexes = true,
  10. double? cacheExtent,
  11. List<Widget> children = const <Widget>[],
  12. int? semanticChildCount,
  13. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  14. Clip clipBehavior = Clip.hardEdge,
  15. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  16. String? restorationId,
})

Creates a scrollable, 2D array of widgets with a custom SliverGridDelegate.

The gridDelegate argument must not be null.

The addAutomaticKeepAlives argument corresponds to the SliverChildListDelegate.addAutomaticKeepAlives property. The addRepaintBoundaries argument corresponds to the SliverChildListDelegate.addRepaintBoundaries property. Both must not be null.

Implementation

GridView({
  required ScrollViewProperties properties,
  Key? key,
  ScrollPhysics? physics,
  bool shrinkWrap = false,
  EdgeInsetsGeometry? padding,
  required this.gridDelegate,
  bool addAutomaticKeepAlives = true,
  bool addRepaintBoundaries = true,
  bool addSemanticIndexes = true,
  double? cacheExtent,
  List<Widget> children = const <Widget>[],
  int? semanticChildCount,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  Clip clipBehavior = Clip.hardEdge,
  ScrollViewKeyboardDismissBehavior keyboardDismissBehavior =
      ScrollViewKeyboardDismissBehavior.manual,
  String? restorationId,
})  : assert(gridDelegate != null),
      childrenDelegate = SliverChildListDelegate(
        children,
        addAutomaticKeepAlives: addAutomaticKeepAlives,
        addRepaintBoundaries: addRepaintBoundaries,
        addSemanticIndexes: addSemanticIndexes,
      ),
      super(
        properties: properties,
        key: key,
        physics: physics,
        shrinkWrap: shrinkWrap,
        padding: padding,
        cacheExtent: cacheExtent,
        semanticChildCount: semanticChildCount ?? children.length,
        dragStartBehavior: dragStartBehavior,
        keyboardDismissBehavior: keyboardDismissBehavior,
        restorationId: restorationId,
        clipBehavior: clipBehavior,
      );