Skip to content

Commit 63e3048

Browse files
authored
Add secondary tap capabilities to TableRowInkWell (#123036)
Added new parameters onSecondaryTap and onSecondaryTapDown
1 parent a5fc8b2 commit 63e3048

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,8 @@ class TableRowInkWell extends InkResponse {
11891189
super.onDoubleTap,
11901190
super.onLongPress,
11911191
super.onHighlightChanged,
1192+
super.onSecondaryTap,
1193+
super.onSecondaryTapDown,
11921194
super.overlayColor,
11931195
super.mouseCursor,
11941196
}) : super(

packages/flutter/test/material/data_table_test.dart

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,51 @@ void main() {
20702070
e.toString().contains('dataRowHeight == null || (dataRowMinHeight == null && dataRowMaxHeight == null)'))));
20712071
});
20722072

2073+
group('TableRowInkWell', () {
2074+
testWidgets('can handle secondary taps', (WidgetTester tester) async {
2075+
bool secondaryTapped = false;
2076+
bool secondaryTappedDown = false;
2077+
2078+
await tester.pumpWidget(MaterialApp(
2079+
home: Material(
2080+
child: Table(
2081+
children: <TableRow>[
2082+
TableRow(
2083+
children: <Widget>[
2084+
TableRowInkWell(
2085+
onSecondaryTap: () {
2086+
secondaryTapped = true;
2087+
},
2088+
onSecondaryTapDown: (TapDownDetails details) {
2089+
secondaryTappedDown = true;
2090+
},
2091+
child: const SizedBox(
2092+
width: 100.0,
2093+
height: 100.0,
2094+
),
2095+
),
2096+
],
2097+
),
2098+
],
2099+
),
2100+
),
2101+
));
2102+
2103+
expect(secondaryTapped, isFalse);
2104+
expect(secondaryTappedDown, isFalse);
2105+
2106+
expect(find.byType(TableRowInkWell), findsOneWidget);
2107+
await tester.tap(
2108+
find.byType(TableRowInkWell),
2109+
buttons: kSecondaryMouseButton,
2110+
);
2111+
await tester.pumpAndSettle();
2112+
2113+
expect(secondaryTapped, isTrue);
2114+
expect(secondaryTappedDown, isTrue);
2115+
});
2116+
});
2117+
20732118
testWidgets('Heading cell cursor resolves MaterialStateMouseCursor correctly', (WidgetTester tester) async {
20742119
await tester.pumpWidget(
20752120
MaterialApp(
@@ -2233,5 +2278,4 @@ void main() {
22332278
// Test that cursor is updated for the row.
22342279
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.copy);
22352280
});
2236-
22372281
}

0 commit comments

Comments
 (0)