Skip to content

Commit 487e6bc

Browse files
authored
Adding onTapDown and onTapCancel to InkWell (flutter#16190)
1 parent 5e94244 commit 487e6bc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/flutter/lib/src/material/ink_well.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ class InkResponse extends StatefulWidget {
192192
Key key,
193193
this.child,
194194
this.onTap,
195+
this.onTapDown,
196+
this.onTapCancel,
195197
this.onDoubleTap,
196198
this.onLongPress,
197199
this.onHighlightChanged,
@@ -218,6 +220,13 @@ class InkResponse extends StatefulWidget {
218220
/// Called when the user taps this part of the material.
219221
final GestureTapCallback onTap;
220222

223+
/// Called when the user taps down this part of the material.
224+
final GestureTapDownCallback onTapDown;
225+
226+
/// Called when the user cancels a tap that was started on this part of the
227+
/// material.
228+
final GestureTapCallback onTapCancel;
229+
221230
/// Called when the user double taps this part of the material.
222231
final GestureTapCallback onDoubleTap;
223232

@@ -464,6 +473,9 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
464473
_splashes ??= new HashSet<InteractiveInkFeature>();
465474
_splashes.add(splash);
466475
_currentSplash = splash;
476+
if (widget.onTapDown != null) {
477+
widget.onTapDown(details);
478+
}
467479
updateKeepAlive();
468480
updateHighlight(true);
469481
}
@@ -482,6 +494,9 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
482494
void _handleTapCancel() {
483495
_currentSplash?.cancel();
484496
_currentSplash = null;
497+
if (widget.onTapCancel != null) {
498+
widget.onTapCancel();
499+
}
485500
updateHighlight(false);
486501
}
487502

@@ -548,7 +563,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
548563
///
549564
/// ![The highlight is a rectangle the size of the box.](https://flutter.github.io/assets-for-api-docs/material/ink_well.png)
550565
///
551-
/// The [InkResponse] widget must have a [Material] widget as an ancestor. The
566+
/// The [InkWell] widget must have a [Material] widget as an ancestor. The
552567
/// [Material] widget is where the ink reactions are actually painted. This
553568
/// matches the material design premise wherein the [Material] is what is
554569
/// actually reacting to touches by spreading ink.
@@ -599,6 +614,8 @@ class InkWell extends InkResponse {
599614
GestureTapCallback onTap,
600615
GestureTapCallback onDoubleTap,
601616
GestureLongPressCallback onLongPress,
617+
GestureTapDownCallback onTapDown,
618+
GestureTapCancelCallback onTapCancel,
602619
ValueChanged<bool> onHighlightChanged,
603620
Color highlightColor,
604621
Color splashColor,
@@ -613,6 +630,8 @@ class InkWell extends InkResponse {
613630
onTap: onTap,
614631
onDoubleTap: onDoubleTap,
615632
onLongPress: onLongPress,
633+
onTapDown: onTapDown,
634+
onTapCancel: onTapCancel,
616635
onHighlightChanged: onHighlightChanged,
617636
containedInkWell: true,
618637
highlightShape: BoxShape.rectangle,

0 commit comments

Comments
 (0)