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 {
),
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,
......
......@@ -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>[
DataRow(
selected: true,
onSelectChanged: (bool? checked) {},
cells: const <DataCell>[
DataCell(Text('Content1')),
......@@ -1323,13 +1332,15 @@ void main() {
);
}
Checkbox lastCheckbox() {
return tester.widgetList<Checkbox>(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 {
......
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