Unverified Commit 47e3f1a9 authored by Will Lockwood's avatar Will Lockwood Committed by GitHub

Allow `Checkbox`es in `DataTable`s to inherit colors from `CheckboxTheme` (#96007)

parent 764c3c18
...@@ -701,9 +701,6 @@ class DataTable extends StatelessWidget { ...@@ -701,9 +701,6 @@ class DataTable extends StatelessWidget {
), ),
child: Center( child: Center(
child: Checkbox( 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, value: checked,
onChanged: onCheckboxChanged, onChanged: onCheckboxChanged,
tristate: tristate, tristate: tristate,
......
...@@ -1298,8 +1298,16 @@ void main() { ...@@ -1298,8 +1298,16 @@ void main() {
); );
}); });
testWidgets('DataRow renders checkbox with colors from Theme', (WidgetTester tester) async { testWidgets('DataRow renders checkbox with colors from CheckboxTheme', (WidgetTester tester) async {
final ThemeData _themeData = ThemeData.light(); 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() { Widget buildTable() {
return MaterialApp( return MaterialApp(
theme: _themeData, theme: _themeData,
...@@ -1312,6 +1320,7 @@ void main() { ...@@ -1312,6 +1320,7 @@ void main() {
], ],
rows: <DataRow>[ rows: <DataRow>[
DataRow( DataRow(
selected: true,
onSelectChanged: (bool? checked) {}, onSelectChanged: (bool? checked) {},
cells: const <DataCell>[ cells: const <DataCell>[
DataCell(Text('Content1')), DataCell(Text('Content1')),
...@@ -1323,13 +1332,15 @@ void main() { ...@@ -1323,13 +1332,15 @@ void main() {
); );
} }
Checkbox lastCheckbox() {
return tester.widgetList<Checkbox>(find.byType(Checkbox)).last;
}
await tester.pumpWidget(buildTable()); 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 { testWidgets('DataRow renders custom colors when selected', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment