Skip to content

Commit

Permalink
Add secondary tap capabilities to TableRowInkWell (flutter#123036)
Browse files Browse the repository at this point in the history
Added new parameters onSecondaryTap and onSecondaryTapDown
  • Loading branch information
justinmc authored and exaby73 committed Apr 17, 2023
1 parent 85d160c commit d801b74
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/flutter/lib/src/material/data_table.dart
Expand Up @@ -1189,6 +1189,8 @@ class TableRowInkWell extends InkResponse {
super.onDoubleTap,
super.onLongPress,
super.onHighlightChanged,
super.onSecondaryTap,
super.onSecondaryTapDown,
super.overlayColor,
super.mouseCursor,
}) : super(
Expand Down
46 changes: 45 additions & 1 deletion packages/flutter/test/material/data_table_test.dart
Expand Up @@ -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>[
TableRow(
children: <Widget>[
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(
Expand Down Expand Up @@ -2233,5 +2278,4 @@ void main() {
// Test that cursor is updated for the row.
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.copy);
});

}

0 comments on commit d801b74

Please sign in to comment.