Adding onTapDown and onTapCancel to InkWell (#16190)
diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart
index e919aed..05155c7 100644
--- a/packages/flutter/lib/src/material/ink_well.dart
+++ b/packages/flutter/lib/src/material/ink_well.dart
@@ -192,6 +192,8 @@
Key key,
this.child,
this.onTap,
+ this.onTapDown,
+ this.onTapCancel,
this.onDoubleTap,
this.onLongPress,
this.onHighlightChanged,
@@ -218,6 +220,13 @@
/// Called when the user taps this part of the material.
final GestureTapCallback onTap;
+ /// Called when the user taps down this part of the material.
+ final GestureTapDownCallback onTapDown;
+
+ /// Called when the user cancels a tap that was started on this part of the
+ /// material.
+ final GestureTapCallback onTapCancel;
+
/// Called when the user double taps this part of the material.
final GestureTapCallback onDoubleTap;
@@ -464,6 +473,9 @@
_splashes ??= new HashSet<InteractiveInkFeature>();
_splashes.add(splash);
_currentSplash = splash;
+ if (widget.onTapDown != null) {
+ widget.onTapDown(details);
+ }
updateKeepAlive();
updateHighlight(true);
}
@@ -482,6 +494,9 @@
void _handleTapCancel() {
_currentSplash?.cancel();
_currentSplash = null;
+ if (widget.onTapCancel != null) {
+ widget.onTapCancel();
+ }
updateHighlight(false);
}
@@ -548,7 +563,7 @@
///
/// ![The highlight is a rectangle the size of the box.](https://flutter.github.io/assets-for-api-docs/material/ink_well.png)
///
-/// The [InkResponse] widget must have a [Material] widget as an ancestor. The
+/// The [InkWell] widget must have a [Material] widget as an ancestor. The
/// [Material] widget is where the ink reactions are actually painted. This
/// matches the material design premise wherein the [Material] is what is
/// actually reacting to touches by spreading ink.
@@ -599,6 +614,8 @@
GestureTapCallback onTap,
GestureTapCallback onDoubleTap,
GestureLongPressCallback onLongPress,
+ GestureTapDownCallback onTapDown,
+ GestureTapCancelCallback onTapCancel,
ValueChanged<bool> onHighlightChanged,
Color highlightColor,
Color splashColor,
@@ -613,6 +630,8 @@
onTap: onTap,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
+ onTapDown: onTapDown,
+ onTapCancel: onTapCancel,
onHighlightChanged: onHighlightChanged,
containedInkWell: true,
highlightShape: BoxShape.rectangle,