onDropped method

void onDropped(
  1. dynamic details
)

Implementation

void onDropped(details) {
  if (!draggable) return;
  _itemGlobalPosition = null;

  final slope = (_itemPosition.dx / _itemPosition.dy).abs();
  var targetPosition = Offset(
    _itemPosition.dx.sign * _screenSize.width * slope,
    _itemPosition.dy.sign * _screenSize.height * slope,
  );

  final magnitude = targetPosition.distance;
  final scaleFactor = magnitude / _screenSize.longestSide;

  targetPosition = Offset(
    targetPosition.dx / scaleFactor,
    targetPosition.dy / scaleFactor,
  );

  final direction =
      _itemPosition.dx < 0 ? DragDirection.left : DragDirection.right;

  _animateItem(
    widget.settings,
    DraggableSliderItemSettings(
      angle: direction == DragDirection.right
          ? Vector3(0, 0, 0.6)
          : Vector3(0, 0, -0.6),
      position: targetPosition,
    ),
  )?.whenComplete(() => widget.onReleased!(widget.key));

  if (widget.onRelease != null) {
    widget.onRelease!(widget.key, direction);
  }
}