m3_lightmeter/lib/data/haptics_service.dart
Vadim 9477f80ada
ML-6 Add support for dynamic colors on A12+ (#8)
* added dynamic colors

* made dynamic colors enabled/disabled

* fixed tests
2023-01-22 22:30:29 +03:00

20 lines
566 B
Dart

import 'package:vibration/vibration.dart';
class HapticsService {
const HapticsService();
Future<void> quickVibration() async => _tryVibrate(duration: 25, amplitude: 96);
Future<void> responseVibration() async => _tryVibrate(duration: 50, amplitude: 128);
Future<void> _tryVibrate({required int duration, required int amplitude}) async {
if (await _canVibrate()) {
Vibration.vibrate(
duration: duration,
amplitude: amplitude,
);
}
}
Future<bool> _canVibrate() async => await Vibration.hasVibrator() ?? false;
}