getPosition function

_SortableDropLocation? getPosition(
  1. Offset position,
  2. Size size, {
  3. bool acceptTop = false,
  4. bool acceptLeft = false,
  5. bool acceptRight = false,
  6. bool acceptBottom = false,
})

Implementation

_SortableDropLocation? getPosition(Offset position, Size size,
    {bool acceptTop = false,
    bool acceptLeft = false,
    bool acceptRight = false,
    bool acceptBottom = false}) {
  double dx = position.dx;
  double dy = position.dy;
  double width = size.width;
  double height = size.height;
  if (acceptTop && !acceptBottom) {
    return _SortableDropLocation.top;
  } else if (acceptBottom && !acceptTop) {
    return _SortableDropLocation.bottom;
  } else if (acceptLeft && !acceptRight) {
    return _SortableDropLocation.left;
  } else if (acceptRight && !acceptLeft) {
    return _SortableDropLocation.right;
  }
  if (acceptTop && dy <= height / 2) {
    return _SortableDropLocation.top;
  }
  if (acceptLeft && dx <= width / 2) {
    return _SortableDropLocation.left;
  }
  if (acceptRight && dx >= width / 2) {
    return _SortableDropLocation.right;
  }
  if (acceptBottom && dy >= height / 2) {
    return _SortableDropLocation.bottom;
  }
  return null;
}