From d801b747e2d4091bb04898154e81659e64bee7e9 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 31 Mar 2023 09:42:16 -0700 Subject: [PATCH] Add secondary tap capabilities to TableRowInkWell (#123036) Added new parameters onSecondaryTap and onSecondaryTapDown --- .../flutter/lib/src/material/data_table.dart | 2 + .../test/material/data_table_test.dart | 46 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index d0d759777e6d..970292c8eaff 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -1189,6 +1189,8 @@ class TableRowInkWell extends InkResponse { super.onDoubleTap, super.onLongPress, super.onHighlightChanged, + super.onSecondaryTap, + super.onSecondaryTapDown, super.overlayColor, super.mouseCursor, }) : super( diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index 98404b0ac38c..6918f5c3cc87 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -2070,6 +2070,51 @@ void main() { e.toString().contains('dataRowHeight == null || (dataRowMinHeight == null && dataRowMaxHeight == null)')))); }); + group('TableRowInkWell', () { + testWidgets('can handle secondary taps', (WidgetTester tester) async { + bool secondaryTapped = false; + bool secondaryTappedDown = false; + + await tester.pumpWidget(MaterialApp( + home: Material( + child: Table( + children: [ + TableRow( + children: [ + TableRowInkWell( + onSecondaryTap: () { + secondaryTapped = true; + }, + onSecondaryTapDown: (TapDownDetails details) { + secondaryTappedDown = true; + }, + child: const SizedBox( + width: 100.0, + height: 100.0, + ), + ), + ], + ), + ], + ), + ), + )); + + expect(secondaryTapped, isFalse); + expect(secondaryTappedDown, isFalse); + + expect(find.byType(TableRowInkWell), findsOneWidget); + await tester.tap( + find.byType(TableRowInkWell), + buttons: kSecondaryMouseButton, + ); + await tester.pumpAndSettle(); + + expect(secondaryTapped, isTrue); + expect(secondaryTappedDown, isTrue); + }); + }); + testWidgets('Heading cell cursor resolves MaterialStateMouseCursor correctly', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( @@ -2233,5 +2278,4 @@ void main() { // Test that cursor is updated for the row. expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.copy); }); - }