@@ -13,14 +13,70 @@ import 'system_channels.dart';
1313class HapticFeedback {
1414 HapticFeedback ._();
1515
16- /// Provides haptic feedback to the user for a short duration.
16+ /// Provides vibration haptic feedback to the user for a short duration.
1717 ///
1818 /// On iOS devices that support haptic feedback, this uses the default system
1919 /// vibration value (`kSystemSoundID_Vibrate` ).
2020 ///
2121 /// On Android, this uses the platform haptic feedback API to simulate a
22- /// short tap on a virtual keyboard .
22+ /// response to a long press ( `HapticFeedbackConstants.LONG_PRESS` ) .
2323 static Future <Null > vibrate () async {
2424 await SystemChannels .platform.invokeMethod ('HapticFeedback.vibrate' );
2525 }
26+
27+ /// Provides a haptic feedback corresponding a collision impact with a light mass.
28+ ///
29+ /// On iOS versions 10 and above, this uses a `UIImpactFeedbackGenerator` with
30+ /// `UIImpactFeedbackStyleLight` . This call has no effects on iOS versions
31+ /// below 10.
32+ ///
33+ /// On Android, this uses `HapticFeedbackConstants.VIRTUAL_KEY` .
34+ static Future <Null > lightImpact () async {
35+ await SystemChannels .platform.invokeMethod (
36+ 'HapticFeedback.vibrate' ,
37+ 'HapticFeedbackType.lightImpact' ,
38+ );
39+ }
40+
41+ /// Provides a haptic feedback corresponding a collision impact with a medium mass.
42+ ///
43+ /// On iOS versions 10 and above, this uses a `UIImpactFeedbackGenerator` with
44+ /// `UIImpactFeedbackStyleMedium` . This call has no effects on iOS versions
45+ /// below 10.
46+ ///
47+ /// On Android, this uses `HapticFeedbackConstants.KEYBOARD_TAP` .
48+ static Future <Null > mediumImpact () async {
49+ await SystemChannels .platform.invokeMethod (
50+ 'HapticFeedback.vibrate' ,
51+ 'HapticFeedbackType.mediumImpact' ,
52+ );
53+ }
54+
55+ /// Provides a haptic feedback corresponding a collision impact with a heavy mass.
56+ ///
57+ /// On iOS versions 10 and above, this uses a `UIImpactFeedbackGenerator` with
58+ /// `UIImpactFeedbackStyleHeavy` . This call has no effects on iOS versions
59+ /// below 10.
60+ ///
61+ /// On Android, this uses `HapticFeedbackConstants.CONTEXT_CLICK` on API levels
62+ /// 23 and above. This call has no effects on Android API levels below 23.
63+ static Future <Null > heavyImpact () async {
64+ await SystemChannels .platform.invokeMethod (
65+ 'HapticFeedback.vibrate' ,
66+ 'HapticFeedbackType.heavyImpact' ,
67+ );
68+ }
69+
70+ /// Provides a haptic feedback indication selection changing through discrete values.
71+ ///
72+ /// On iOS versions 10 and above, this uses a `UISelectionFeedbackGenerator` .
73+ /// This call has no effects on iOS versions below 10.
74+ ///
75+ /// On Android, this uses `HapticFeedbackConstants.CLOCK_TICK` .
76+ static Future <Null > selectionClick () async {
77+ await SystemChannels .platform.invokeMethod (
78+ 'HapticFeedback.vibrate' ,
79+ 'HapticFeedbackType.selectionClick' ,
80+ );
81+ }
2682}
0 commit comments