@@ -14,6 +14,7 @@ import 'dart:ui' show ImageFilter, lerpDouble;
14
14
import 'package:flutter/foundation.dart' ;
15
15
import 'package:flutter/gestures.dart' ;
16
16
import 'package:flutter/rendering.dart' ;
17
+ import 'package:flutter/services.dart' ;
17
18
import 'package:flutter/widgets.dart' ;
18
19
19
20
import 'colors.dart' ;
@@ -595,7 +596,10 @@ abstract class _ActionSheetSlideTarget {
595
596
// * The point has contacted the screen in this region. In this case, this
596
597
// method is called as soon as the pointer down event occurs regardless of
597
598
// whether the gesture wins the arena immediately.
598
- void didEnter ();
599
+ //
600
+ // The `fromPointerDown` should be true if this callback is triggered by a
601
+ // PointerDownEvent, i.e. the second case from the list above.
602
+ void didEnter ({required bool fromPointerDown});
599
603
600
604
// A pointer has exited this region.
601
605
//
@@ -660,7 +664,10 @@ class _TargetSelectionGestureRecognizer extends GestureRecognizer {
660
664
// Collect the `_ActionSheetSlideTarget`s that are currently hit by the
661
665
// pointer, check whether the current target have changed, and invoke their
662
666
// methods if necessary.
663
- void _updateDrag (Offset pointerPosition) {
667
+ //
668
+ // The `fromPointerDown` should be true if this update is triggered by a
669
+ // PointerDownEvent.
670
+ void _updateDrag (Offset pointerPosition, {required bool fromPointerDown}) {
664
671
final HitTestResult result = hitTest (pointerPosition);
665
672
666
673
// A slide target might nest other targets, therefore multiple targets might
@@ -686,21 +693,21 @@ class _TargetSelectionGestureRecognizer extends GestureRecognizer {
686
693
..clear ()
687
694
..addAll (foundTargets);
688
695
for (final _ActionSheetSlideTarget target in _currentTargets) {
689
- target.didEnter ();
696
+ target.didEnter (fromPointerDown : fromPointerDown );
690
697
}
691
698
}
692
699
}
693
700
694
701
void _onDown (DragDownDetails details) {
695
- _updateDrag (details.globalPosition);
702
+ _updateDrag (details.globalPosition, fromPointerDown : true );
696
703
}
697
704
698
705
void _onUpdate (Offset globalPosition) {
699
- _updateDrag (globalPosition);
706
+ _updateDrag (globalPosition, fromPointerDown : false );
700
707
}
701
708
702
709
void _onEnd (Offset globalPosition) {
703
- _updateDrag (globalPosition);
710
+ _updateDrag (globalPosition, fromPointerDown : false );
704
711
for (final _ActionSheetSlideTarget target in _currentTargets) {
705
712
target.didConfirm ();
706
713
}
@@ -1121,7 +1128,7 @@ class _CupertinoActionSheetActionState extends State<CupertinoActionSheetAction>
1121
1128
implements _ActionSheetSlideTarget {
1122
1129
// |_ActionSheetSlideTarget|
1123
1130
@override
1124
- void didEnter () {}
1131
+ void didEnter ({ required bool fromPointerDown} ) {}
1125
1132
1126
1133
// |_ActionSheetSlideTarget|
1127
1134
@override
@@ -1243,11 +1250,27 @@ class _ActionSheetButtonBackground extends StatefulWidget {
1243
1250
class _ActionSheetButtonBackgroundState extends State <_ActionSheetButtonBackground > implements _ActionSheetSlideTarget {
1244
1251
bool isBeingPressed = false ;
1245
1252
1253
+ void _emitVibration (){
1254
+ switch (defaultTargetPlatform) {
1255
+ case TargetPlatform .iOS:
1256
+ case TargetPlatform .android:
1257
+ HapticFeedback .selectionClick ();
1258
+ case TargetPlatform .fuchsia:
1259
+ case TargetPlatform .linux:
1260
+ case TargetPlatform .macOS:
1261
+ case TargetPlatform .windows:
1262
+ break ;
1263
+ }
1264
+ }
1265
+
1246
1266
// |_ActionSheetSlideTarget|
1247
1267
@override
1248
- void didEnter () {
1268
+ void didEnter ({ required bool fromPointerDown} ) {
1249
1269
setState (() { isBeingPressed = true ; });
1250
1270
widget.onPressStateChange? .call (true );
1271
+ if (! fromPointerDown) {
1272
+ _emitVibration ();
1273
+ }
1251
1274
}
1252
1275
1253
1276
// |_ActionSheetSlideTarget|
0 commit comments