hasCustomVibrationsSupport static method

Future<bool?> hasCustomVibrationsSupport()

Check if the device is able to vibrate with a custom duration, pattern or intensities. May return true even if the device has no vibrator.

if (await Vibration.hasCustomVibrationsSupport()) {
  Vibration.vibrate(duration: 1000);
} else {
  Vibration.vibrate();
  await Future.delayed(Duration(milliseconds: 500));
  Vibration.vibrate();
}

Implementation

static Future<bool?> hasCustomVibrationsSupport() async {
  try {
    return await _channel.invokeMethod("hasCustomVibrationsSupport");
  } on MissingPluginException {
    return Future.value(false);
  }
}