diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 64f5fc089f..73eb1ef53c 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -100,7 +100,6 @@ class DataRow { this.selected = false, this.onSelectChanged, this.onLongPress, - this.selectableOnGestures = true, this.color, required this.cells, }) : assert(cells != null); @@ -114,7 +113,6 @@ class DataRow { this.selected = false, this.onSelectChanged, this.onLongPress, - this.selectableOnGestures = true, this.color, required this.cells, }) : assert(cells != null), @@ -165,18 +163,6 @@ class DataRow { /// Otherwise, the checkbox, if present, will not be checked. final bool selected; - /// Whether the row can be selected by using gestures such as - /// tap or long press. - /// - /// If the value is set to false and [onSelectChanged] is non-null, - /// the row can be only selected by toggling the checkbox. - /// - /// If the value is set to false and [onLongPress] is non-null, - /// [onLongPress] callback won't be called. - /// - /// This value is true by default. - final bool selectableOnGestures; - /// The data for this row. /// /// There must be exactly as many cells as there are columns in the @@ -821,7 +807,6 @@ class DataTable extends StatelessWidget { required GestureTapCancelCallback? onTapCancel, required MaterialStateProperty? overlayColor, required GestureLongPressCallback? onRowLongPress, - required bool selectableOnGestures, }) { final ThemeData themeData = Theme.of(context); final DataTableThemeData dataTableTheme = DataTableTheme.of(context); @@ -867,7 +852,7 @@ class DataTable extends StatelessWidget { overlayColor: overlayColor, child: label, ); - } else if (selectableOnGestures && (onSelectChanged != null || onRowLongPress != null)) { + } else if (onSelectChanged != null || onRowLongPress != null) { label = TableRowInkWell( onTap: onSelectChanged, onLongPress: onRowLongPress, @@ -1046,7 +1031,6 @@ class DataTable extends StatelessWidget { onSelectChanged: row.onSelectChanged == null ? null : () => row.onSelectChanged?.call(!row.selected), overlayColor: row.color ?? effectiveDataRowColor, onRowLongPress: row.onLongPress, - selectableOnGestures: row.selectableOnGestures, ); rowIndex += 1; } diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index 034a781e57..89758049f9 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -293,84 +293,6 @@ void main() { log.clear(); }); - testWidgets('selectableOnGestures disables gestures on row', (WidgetTester tester) async { - final List log = []; - - Widget buildTable({ int? sortColumnIndex, bool sortAscending = true }) { - return DataTable( - sortColumnIndex: sortColumnIndex, - sortAscending: sortAscending, - onSelectAll: (bool? value) { - log.add('select-all: $value'); - }, - columns: [ - const DataColumn( - label: Text('Name'), - tooltip: 'Name', - ), - DataColumn( - label: const Text('Calories'), - tooltip: 'Calories', - numeric: true, - onSort: (int columnIndex, bool ascending) { - log.add('column-sort: $columnIndex $ascending'); - }, - ), - ], - rows: kDesserts.map((Dessert dessert) { - return DataRow( - key: ValueKey(dessert.name), - selectableOnGestures: false, - onSelectChanged: (bool? selected) { - log.add('row-selected: ${dessert.name}'); - }, - onLongPress: () { - log.add('onLongPress: ${dessert.name}'); - }, - cells: [ - DataCell( - Text(dessert.name), - ), - DataCell( - Text('${dessert.calories}'), - showEditIcon: true, - onTap: () { - log.add('cell-tap: ${dessert.calories}'); - }, - onDoubleTap: () { - log.add('cell-doubleTap: ${dessert.calories}'); - }, - onLongPress: () { - log.add('cell-longPress: ${dessert.calories}'); - }, - onTapCancel: () { - log.add('cell-tapCancel: ${dessert.calories}'); - }, - onTapDown: (TapDownDetails details) { - log.add('cell-tapDown: ${dessert.calories}'); - }, - ), - ], - ); - }).toList(), - ); - } - - await tester.pumpWidget(MaterialApp( - home: Material(child: buildTable()), - )); - - await tester.tap(find.text('KitKat')); - expect(log.length, 0); - - await tester.longPress(find.text('KitKat')); - expect(log.length, 0); - - await tester.tap(find.byType(Checkbox).last); - expect(log, ['row-selected: KitKat']); - log.clear(); - }); - testWidgets('DataTable overflow test - header', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp(