stickyMinuteHand method
void
stickyMinuteHand()
Implementation
void stickyMinuteHand() {
//search angle beetween all possible angles
for (int i = 0; i < minutesAngles.length; i++) {
if (i < minutesAngles.length - 1) {
double angle1 = minutesAngles[i];
double angle2 = minutesAngles[i + 1];
if (controller.value > angle1 && controller.value < angle2) {
//calculate current hand angle distance beetween previous and next possible angle
double angleDistance1 = (controller.value - angle1).abs();
double angleDistance2 = (controller.value - angle2).abs();
//assign the closest possible angle from current hand angle
if (angleDistance1 > angleDistance2) {
controller
.animateTo(angle2, duration: const Duration(milliseconds: 100))
.whenComplete(() {
onDragHandleEnd(((controller.value / 360) * 60).toInt());
});
} else {
controller
.animateTo(angle1, duration: const Duration(milliseconds: 100))
.whenComplete(() {
onDragHandleEnd(((controller.value / 360) * 60).toInt());
});
}
break;
}
}
}
}