Skip to content

Commit d4a9631

Browse files
authored
Revert "[DataTable]: Add ability to only select row using checkbox (#105123)" (#105311)
1 parent 5fe7854 commit d4a9631

File tree

2 files changed

+1
-95
lines changed

2 files changed

+1
-95
lines changed

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class DataRow {
100100
this.selected = false,
101101
this.onSelectChanged,
102102
this.onLongPress,
103-
this.selectableOnGestures = true,
104103
this.color,
105104
required this.cells,
106105
}) : assert(cells != null);
@@ -114,7 +113,6 @@ class DataRow {
114113
this.selected = false,
115114
this.onSelectChanged,
116115
this.onLongPress,
117-
this.selectableOnGestures = true,
118116
this.color,
119117
required this.cells,
120118
}) : assert(cells != null),
@@ -165,18 +163,6 @@ class DataRow {
165163
/// Otherwise, the checkbox, if present, will not be checked.
166164
final bool selected;
167165

168-
/// Whether the row can be selected by using gestures such as
169-
/// tap or long press.
170-
///
171-
/// If the value is set to false and [onSelectChanged] is non-null,
172-
/// the row can be only selected by toggling the checkbox.
173-
///
174-
/// If the value is set to false and [onLongPress] is non-null,
175-
/// [onLongPress] callback won't be called.
176-
///
177-
/// This value is true by default.
178-
final bool selectableOnGestures;
179-
180166
/// The data for this row.
181167
///
182168
/// There must be exactly as many cells as there are columns in the
@@ -821,7 +807,6 @@ class DataTable extends StatelessWidget {
821807
required GestureTapCancelCallback? onTapCancel,
822808
required MaterialStateProperty<Color?>? overlayColor,
823809
required GestureLongPressCallback? onRowLongPress,
824-
required bool selectableOnGestures,
825810
}) {
826811
final ThemeData themeData = Theme.of(context);
827812
final DataTableThemeData dataTableTheme = DataTableTheme.of(context);
@@ -867,7 +852,7 @@ class DataTable extends StatelessWidget {
867852
overlayColor: overlayColor,
868853
child: label,
869854
);
870-
} else if (selectableOnGestures && (onSelectChanged != null || onRowLongPress != null)) {
855+
} else if (onSelectChanged != null || onRowLongPress != null) {
871856
label = TableRowInkWell(
872857
onTap: onSelectChanged,
873858
onLongPress: onRowLongPress,
@@ -1046,7 +1031,6 @@ class DataTable extends StatelessWidget {
10461031
onSelectChanged: row.onSelectChanged == null ? null : () => row.onSelectChanged?.call(!row.selected),
10471032
overlayColor: row.color ?? effectiveDataRowColor,
10481033
onRowLongPress: row.onLongPress,
1049-
selectableOnGestures: row.selectableOnGestures,
10501034
);
10511035
rowIndex += 1;
10521036
}

packages/flutter/test/material/data_table_test.dart

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -293,84 +293,6 @@ void main() {
293293
log.clear();
294294
});
295295

296-
testWidgets('selectableOnGestures disables gestures on row', (WidgetTester tester) async {
297-
final List<String> log = <String>[];
298-
299-
Widget buildTable({ int? sortColumnIndex, bool sortAscending = true }) {
300-
return DataTable(
301-
sortColumnIndex: sortColumnIndex,
302-
sortAscending: sortAscending,
303-
onSelectAll: (bool? value) {
304-
log.add('select-all: $value');
305-
},
306-
columns: <DataColumn>[
307-
const DataColumn(
308-
label: Text('Name'),
309-
tooltip: 'Name',
310-
),
311-
DataColumn(
312-
label: const Text('Calories'),
313-
tooltip: 'Calories',
314-
numeric: true,
315-
onSort: (int columnIndex, bool ascending) {
316-
log.add('column-sort: $columnIndex $ascending');
317-
},
318-
),
319-
],
320-
rows: kDesserts.map<DataRow>((Dessert dessert) {
321-
return DataRow(
322-
key: ValueKey<String>(dessert.name),
323-
selectableOnGestures: false,
324-
onSelectChanged: (bool? selected) {
325-
log.add('row-selected: ${dessert.name}');
326-
},
327-
onLongPress: () {
328-
log.add('onLongPress: ${dessert.name}');
329-
},
330-
cells: <DataCell>[
331-
DataCell(
332-
Text(dessert.name),
333-
),
334-
DataCell(
335-
Text('${dessert.calories}'),
336-
showEditIcon: true,
337-
onTap: () {
338-
log.add('cell-tap: ${dessert.calories}');
339-
},
340-
onDoubleTap: () {
341-
log.add('cell-doubleTap: ${dessert.calories}');
342-
},
343-
onLongPress: () {
344-
log.add('cell-longPress: ${dessert.calories}');
345-
},
346-
onTapCancel: () {
347-
log.add('cell-tapCancel: ${dessert.calories}');
348-
},
349-
onTapDown: (TapDownDetails details) {
350-
log.add('cell-tapDown: ${dessert.calories}');
351-
},
352-
),
353-
],
354-
);
355-
}).toList(),
356-
);
357-
}
358-
359-
await tester.pumpWidget(MaterialApp(
360-
home: Material(child: buildTable()),
361-
));
362-
363-
await tester.tap(find.text('KitKat'));
364-
expect(log.length, 0);
365-
366-
await tester.longPress(find.text('KitKat'));
367-
expect(log.length, 0);
368-
369-
await tester.tap(find.byType(Checkbox).last);
370-
expect(log, <String>['row-selected: KitKat']);
371-
log.clear();
372-
});
373-
374296
testWidgets('DataTable overflow test - header', (WidgetTester tester) async {
375297
await tester.pumpWidget(
376298
MaterialApp(

0 commit comments

Comments
 (0)