reorderStart method

bool reorderStart(
  1. BuildContext context,
  2. double dx,
  3. double dy
)

Implementation

bool reorderStart(BuildContext context, double dx, double dy) {
  if (isReordering) return false;

  final slot = childManager.buildIndexFromContext(context);
  if (slot == null || slot.popUpList != null) return false;

  final r = childManager.oldIndexToNewIndex(slot.index, slot.popUpList);
  if (r.newIndex == null || r.needsRebuild || r.discardElement) return false;
  final buildIndex = r.newIndex!;

  final interval = intervalManager.list.intervalAtBuildIndex(buildIndex);
  if (interval is! _NormalInterval) {
    return false;
  }

  final child = childManager.renderBoxAt(slot.index);
  if (child == null) return false;

  final childOffset = parentDataOf(child)?.layoutOffset;
  if (childOffset == null) return false;

  final itemSize = paintExtentOf(child);

  final offset = buildIndex - interval.buildOffset;
  final itemIndex = interval.itemOffset + offset;

  final delegate = childManager.widget.delegate;
  if (!(delegate.reorderModel?.onReorderStart.call(itemIndex, dx, dy) ??
      false)) return false;

  final rslot = delegate.reorderModel?.onReorderFeedback
      .call(itemIndex, itemIndex, childOffset, 0.0, 0.0);

  _reorderLayoutData =
      _ReorderLayoutData(constraints, childOffset, dx, dy, itemSize, rslot);

  intervalManager.reorderStart(
      _reorderLayoutData!, interval, offset, itemIndex);

  markSafeNeedsLayout();

  return true;
}