[iOS] fixed vibration

This commit is contained in:
Vadim 2024-02-12 15:41:19 +01:00
parent f307676ca5
commit d631f41589

View file

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:vibration/vibration.dart'; import 'package:vibration/vibration.dart';
class HapticsService { class HapticsService {
@ -11,10 +13,17 @@ class HapticsService {
Future<void> _tryVibrate({required int duration, required int amplitude}) async { Future<void> _tryVibrate({required int duration, required int amplitude}) async {
if (await _canVibrate()) { if (await _canVibrate()) {
await Vibration.vibrate( if (Platform.isAndroid) {
duration: duration, await Vibration.vibrate(
amplitude: amplitude, duration: duration,
); amplitude: amplitude,
);
} else {
await Vibration.vibrate(
pattern: [duration],
intensities: [amplitude],
);
}
} }
} }