diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 4aa24900d7..9fb0dc6147 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -701,9 +701,6 @@ class DataTable extends StatelessWidget { ), child: Center( child: Checkbox( - // TODO(per): Remove when Checkbox has theme, https://github.com/flutter/flutter/issues/53420. - activeColor: themeData.colorScheme.primary, - checkColor: themeData.colorScheme.onPrimary, value: checked, onChanged: onCheckboxChanged, tristate: tristate, diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index 6858a96037..aa781ff2e1 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -1298,8 +1298,16 @@ void main() { ); }); - testWidgets('DataRow renders checkbox with colors from Theme', (WidgetTester tester) async { - final ThemeData _themeData = ThemeData.light(); + testWidgets('DataRow renders checkbox with colors from CheckboxTheme', (WidgetTester tester) async { + const Color fillColor = Color(0xFF00FF00); + const Color checkColor = Color(0xFF0000FF); + + final ThemeData _themeData = ThemeData( + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.all(fillColor), + checkColor: MaterialStateProperty.all(checkColor), + ), + ); Widget buildTable() { return MaterialApp( theme: _themeData, @@ -1312,6 +1320,7 @@ void main() { ], rows: [ DataRow( + selected: true, onSelectChanged: (bool? checked) {}, cells: const [ DataCell(Text('Content1')), @@ -1323,13 +1332,15 @@ void main() { ); } - Checkbox lastCheckbox() { - return tester.widgetList(find.byType(Checkbox)).last; - } - await tester.pumpWidget(buildTable()); - expect(lastCheckbox().activeColor, _themeData.colorScheme.primary); - expect(lastCheckbox().checkColor, _themeData.colorScheme.onPrimary); + + expect( + Material.of(tester.element(find.byType(Checkbox).last)), + paints + ..path() + ..path(color: fillColor) + ..path(color: checkColor), + ); }); testWidgets('DataRow renders custom colors when selected', (WidgetTester tester) async {