Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secondary tap capabilities to TableRowInkWell #123036

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/flutter/lib/src/material/data_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,8 @@ class TableRowInkWell extends InkResponse {
super.onDoubleTap,
super.onLongPress,
super.onHighlightChanged,
super.onSecondaryTap,
super.onSecondaryTapDown,
super.overlayColor,
}) : super(
containedInkWell: true,
Expand Down
45 changes: 45 additions & 0 deletions packages/flutter/test/material/data_table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2072,4 +2072,49 @@ void main() {
expect(() => createDataTable(dataRowHeight: 1.0, dataRowMinHeight: 2.0), throwsA(predicate((AssertionError e) =>
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);
});
});
}