Files
barcode_reader_pc/app/lib/services/feedback_service.dart
T

27 lines
584 B
Dart

import 'package:flutter/services.dart';
class FeedbackService {
static Future<void> triggerFeedback({bool sound = true, bool vibrate = true}) async {
try {
if (vibrate) {
await HapticFeedback.mediumImpact();
}
if (sound) {
await SystemSound.play(SystemSoundType.click);
}
} catch (_) {}
}
static Future<void> triggerSuccess() async {
try {
await HapticFeedback.heavyImpact();
} catch (_) {}
}
static Future<void> triggerError() async {
try {
await HapticFeedback.vibrate();
} catch (_) {}
}
}