provideHapticFeedback static method

void provideHapticFeedback({
  1. ToastType type = ToastType.DEFAULT,
  2. dynamic successCustomVibration()?,
  3. dynamic errorVibration()?,
  4. bool? vibrate,
})

Implementation

static void provideHapticFeedback(
    {ToastType type = ToastType.DEFAULT,
    Function()? successCustomVibration,
    Function()? errorVibration,
    bool? vibrate}) {
  if (vibrate != null && !vibrate) return;
  switch (type) {
    case ToastType.SUCCESS:
      if (successCustomVibration == null) {
        HapticFeedback.selectionClick();
      } else {
        successCustomVibration();
      }
      break;
    case ToastType.ERROR:
      errorVibration ?? HapticFeedback.heavyImpact();
      break;
    case ToastType.INFO:
      HapticFeedback.mediumImpact();
      break;
    case ToastType.DEFAULT:
      HapticFeedback.vibrate();
      break;
    default:
      HapticFeedback.lightImpact();
      break;
  }
}