import 'package:vibration/vibration.dart'; /// A service to handle notifications and vibration class NotificationManager { static final NotificationManager _instance = NotificationManager._internal(); factory NotificationManager() { return _instance; } NotificationManager._internal(); /// Vibrate the device to notify user of timer completion Future notifyTimerCompletion() async { await triggerVibration(); } /// Trigger vibration pattern Future triggerVibration() async { if (await Vibration.hasVibrator() ?? false) { // Pattern for stronger notification - will repeat 3 times with pauses // Vibrate for 500ms, pause for 200ms, repeat Vibration.vibrate( pattern: [0, 500, 200, 500, 200, 500], intensities: [0, 255, 0, 255, 0, 255], ); } } /// Stop vibration Future stopVibration() async { if (await Vibration.hasVibrator() ?? false) { Vibration.cancel(); } } }