HcDragAndDropView.horizontalStickyHeader constructor

const HcDragAndDropView.horizontalStickyHeader({
  1. Key? key,
  2. bool reverse = false,
  3. ScrollController? controller,
  4. bool? primary,
  5. ScrollPhysics? physics,
  6. bool isCustomFeedback = false,
  7. bool isCustomChildWhenDragging = false,
  8. required WillAcceptCallback onWillAccept,
  9. WillAcceptCallback? onWillAcceptHeader,
  10. required IndexedWidgetBuilder itemBuilderHeader,
  11. bool allHeaderChildNonDraggable = false,
  12. SliverGridDelegate? headerGridDelegate,
  13. required ReorderCallback onReorder,
  14. ReorderCallback? onReorderHeader,
  15. int? headerItemCount,
  16. EdgeInsetsGeometry? headerPadding,
  17. EdgeInsetsGeometry? padding,
  18. required SliverGridDelegate gridDelegate,
  19. required IndexedWidgetBuilder itemBuilder,
  20. int? itemCount,
  21. bool addAutomaticKeepAlives = true,
  22. bool addRepaintBoundaries = true,
  23. bool addSemanticIndexes = true,
  24. double? cacheExtent,
  25. int? semanticChildCount,
  26. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  27. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  28. WidgetPositionBuilder? feedback,
  29. WidgetPositionBuilder? childWhenDragging,
})

To achive the sticky header in horizontal gridview just call this horizontalStickyHeader constructor. By Default allHeaderChildNonDraggable is set to false making all header draggable. onWillAcceptHeader (Implement your logic on accepting and rejecting the drop of an header element), onReorderHeader (implement your logic for reodering and reindexing the elements) And if you want the header to be non-draggable element simple set allHeaderChildNonDraggable to true. itemBuilderHeader will be called only with indices greater than or equal to

Providing a non-null itemCount improves the ability of the GridView to estimate the maximum scroll extent.

itemBuilder will be called only with indices greater than or equal to zero and less than itemCount.

The gridDelegate argument must not be null.

The addAutomaticKeepAlives argument corresponds to the SliverChildBuilderDelegate.addAutomaticKeepAlives property. The addRepaintBoundaries argument corresponds to the SliverChildBuilderDelegate.addRepaintBoundaries property. Both must not be null. this onReorder have the old index and new index. Called when an acceptable piece of data was dropped over this grid child. onWillAccept this funciton allows you to validate if you want to accept the change in the order of the gridViewItems. If you always want to accept the change simply return true

Implementation

/// By Default allHeaderChildNonDraggable is set to false making all header draggable.

/// [onWillAcceptHeader] (Implement your logic on accepting and rejecting the drop of an header element),

/// [onReorderHeader] (implement your logic for reodering and reindexing the elements)

/// And if you want the header to be non-draggable element simple set [allHeaderChildNonDraggable] to true.

///  [itemBuilderHeader] will be called only with indices greater than or equal to
///
///
/// Providing a non-null `itemCount` improves the ability of the [GridView] to
/// estimate the maximum scroll extent.
///
/// `itemBuilder` will be called only with indices greater than or equal to
/// zero and less than `itemCount`.
///
/// The [gridDelegate] argument must not be null.
///
/// The `addAutomaticKeepAlives` argument corresponds to the
/// [SliverChildBuilderDelegate.addAutomaticKeepAlives] property. The
/// `addRepaintBoundaries` argument corresponds to the
/// [SliverChildBuilderDelegate.addRepaintBoundaries] property. Both must not
/// be null.
/// this [onReorder] have the old index and new index. Called when an acceptable piece of data was dropped over this grid child.
/// [onWillAccept] this funciton allows you to validate if you want to accept the change in the order of the gridViewItems.
///  If you always want to accept the change simply return true
const HcDragAndDropView.horizontalStickyHeader({
  Key? key,
  bool reverse = false,
  ScrollController? controller,
  bool? primary,
  ScrollPhysics? physics,
  bool isCustomFeedback = false,
  bool isCustomChildWhenDragging = false,
  required WillAcceptCallback onWillAccept,
  WillAcceptCallback? onWillAcceptHeader,
  required IndexedWidgetBuilder itemBuilderHeader,
  bool allHeaderChildNonDraggable = false,
  SliverGridDelegate? headerGridDelegate,
  required ReorderCallback onReorder,
  ReorderCallback? onReorderHeader,
  int? headerItemCount,
  EdgeInsetsGeometry? headerPadding,
  EdgeInsetsGeometry? padding,
  required SliverGridDelegate gridDelegate,
  required IndexedWidgetBuilder itemBuilder,
  int? itemCount,
  bool addAutomaticKeepAlives = true,
  bool addRepaintBoundaries = true,
  bool addSemanticIndexes = true,
  double? cacheExtent,
  int? semanticChildCount,
  DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  ScrollViewKeyboardDismissBehavior keyboardDismissBehavior =
      ScrollViewKeyboardDismissBehavior.manual,
  WidgetPositionBuilder? feedback,
  WidgetPositionBuilder? childWhenDragging,
}) : super(
          key: key,
          reverse: reverse,
          itemBuilder: itemBuilder,
          onWillAccept: onWillAccept,
          feedback: feedback,
          onReorder: onReorder,
          onReorderHeader: onReorderHeader,
          onWillAcceptHeader: onWillAcceptHeader,
          childWhenDragging: childWhenDragging,
          controller: controller,
          padding: padding,
          semanticChildCount: semanticChildCount,
          physics: physics,
          addAutomaticKeepAlive: addAutomaticKeepAlives,
          addRepaintBoundaries: addRepaintBoundaries,
          addSemanticIndexes: addSemanticIndexes,
          cacheExtent: cacheExtent,
          itemCount: itemCount,
          primary: primary,
          isCustomFeedback: isCustomFeedback,
          isCustomChildWhenDragging: isCustomChildWhenDragging,
          gridDelegate: gridDelegate,
          dragStartBehavior: dragStartBehavior,
          keyboardDismissBehavior: keyboardDismissBehavior,
          itemBuilderHeader: itemBuilderHeader,
          isStickyHeader: true,
          allHeaderChildNonDraggable: allHeaderChildNonDraggable,
          headerPadding: headerPadding,
          headerGridDelegate: headerGridDelegate,
          headerItemCount: headerItemCount,
          isVertical: false);