onPanStart method
Implementation
void onPanStart(DragStartDetails details) {
if (widget.controller.isEdit) {
var x = details.localPosition.dx;
var y = details.localPosition.dy;
var handle = widget.controller.radius * 2;
for (var j = widget.controller.lines.length - 1; j >= 0; j--) {
var m = widget.controller.lines[j];
for (var i = 0; i < m.line.length; i++) {
var line = m.line[i];
if (x > line.dx - handle &&
x < line.dx + handle &&
y > line.dy - handle &&
y < line.dy + handle) {
lineIndex = i;
pathIndex = j;
dragDot = true;
break;
}
}
if (lineIndex == -1 && pathIndex == -1) {
if (m.contain(details.localPosition)) {
dragDot = false;
pathIndex = j;
widget.controller.selectPathIndex = j;
break;
}
}
}
} else {
List<PathBean> lines = [];
for (var m in widget.controller.lines) {
Path path = Path();
for (var j = 0; j < m.line.length; j++) {
var line = m.line[j];
if (j == 0) {
path.moveTo(line.dx, line.dy);
} else {
path.lineTo(line.dx, line.dy);
}
}
path.close();
if (path.contains(details.localPosition)) {
lines.add(m);
}
}
widget.onShapeTap?.call(lines);
}
}