DragSelectGridView constructor

DragSelectGridView({
  1. Key? key,
  2. double? autoScrollHotspotHeight,
  3. ScrollController? scrollController,
  4. DragSelectGridViewController? gridController,
  5. bool triggerSelectionOnTap = false,
  6. bool reverse = false,
  7. bool? primary,
  8. ScrollPhysics? physics,
  9. bool shrinkWrap = false,
  10. EdgeInsetsGeometry? padding,
  11. required SliverGridDelegate gridDelegate,
  12. required SelectableWidgetBuilder itemBuilder,
  13. int? itemCount,
  14. bool addAutomaticKeepAlives = true,
  15. bool addRepaintBoundaries = true,
  16. bool addSemanticIndexes = true,
  17. double? cacheExtent,
  18. int? semanticChildCount,
  19. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  20. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  21. String? restorationId,
  22. Clip clipBehavior = Clip.hardEdge,
})

Creates a grid that supports both dragging and tapping to select its items.

It is possible to customize the height of the hotspot that enables auto-scroll by specifying autoScrollHotspotHeight.

The gridController provides information that can be used to update the UI to indicate whether there are selected items and how many are selected, besides allowing to directly update the selected items.

By leaving unselectOnWillPop false, the items won't get unselected when the user tries to pop the route.

The itemBuilder must be used to create widgets based on the index and whether they are selected or not.

For information about the clause of the other parameters, refer to GridView.builder.

Implementation

DragSelectGridView({
  Key? key,
  double? autoScrollHotspotHeight,
  ScrollController? scrollController,
  this.gridController,
  this.triggerSelectionOnTap = false,
  this.reverse = false,
  this.primary,
  this.physics,
  this.shrinkWrap = false,
  this.padding,
  required this.gridDelegate,
  required this.itemBuilder,
  this.itemCount,
  this.addAutomaticKeepAlives = true,
  this.addRepaintBoundaries = true,
  this.addSemanticIndexes = true,
  this.cacheExtent,
  this.semanticChildCount,
  this.dragStartBehavior = DragStartBehavior.start,
  this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  this.restorationId,
  this.clipBehavior = Clip.hardEdge,
})  : autoScrollHotspotHeight =
          autoScrollHotspotHeight ?? defaultAutoScrollHotspotHeight,
      scrollController = scrollController ?? ScrollController(),
      super(key: key);