I want to run haptic feedback when sliding with flutter slidable

145 Views Asked by At

I want to execute haptic feedback at the start of a slide, not onTap or onDismissible.

The method of using a listener to execute the feedback is implemented, but this sometimes results in a timing error in the haptic feedback.

 onPointerDown: (PointerDownEvent event) {
  startOffset = event.position;
},
onPointerMove: (PointerMoveEvent move) {
  double dx = move.localPosition.dx -
      startOffset!.dx;
  if (dx > 15 && isRight) {
    isRight = false;
    isLeft = true;
    HapticFeedback.lightImpact();
  } else if (dx < -15 && isLeft) {
    isLeft = false;
    isRight = true;
    HapticFeedback.lightImpact();
  }
},
onPointerUp: (PointerUpEvent event) {
  isRight = true;
  isLeft = true;
},
0

There are 0 best solutions below