swipe static method

AudioRule swipe({
  1. String audioPath = 'swipe.mp3',
  2. double minVelocity = 500.0,
})

A rule triggered on horizontal swipe with minimum velocity.

Implementation

static AudioRule swipe({
  String audioPath = 'swipe.mp3',
  double minVelocity = 500.0,
}) {
  return AudioRule(
    audioPath: audioPath,
    volume: 0.8,
    pitch: 1.0 + (minVelocity / 1000.0),
    hapticType: HapticsType.light,
    condition: (context, data) {
      if (data is DragUpdateDetails) {
        final velocity = data.delta.distance / 0.016;
        return velocity >= minVelocity;
      }
      return false;
    },
  );
}