import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'dart:io' show Platform; class HapticUtils { static bool get isSupported { try { return !kIsWeb && (Platform.isAndroid || Platform.isIOS); } catch (e) { return false; } } static Future lightImpact() async { if (!isSupported) return; try { await HapticFeedback.lightImpact(); } catch (e) { // Silently ignore haptic feedback errors } } static Future mediumImpact() async { if (!isSupported) return; try { await HapticFeedback.mediumImpact(); } catch (e) { // Silently ignore haptic feedback errors } } static Future heavyImpact() async { if (!isSupported) return; try { await HapticFeedback.heavyImpact(); } catch (e) { // Silently ignore haptic feedback errors } } static Future vibrate({int duration = 50}) async { if (!isSupported) return; try { // Use appropriate haptic feedback based on duration if (duration <= 30) { await HapticFeedback.lightImpact(); } else if (duration <= 60) { await HapticFeedback.mediumImpact(); } else { await HapticFeedback.heavyImpact(); } } catch (e) { // Silently ignore haptic feedback errors } } }