@@ -13,9 +13,10 @@ Widget wrapForChip({
1313 TextDirection textDirection = TextDirection .ltr,
1414 double textScaleFactor = 1.0 ,
1515 Brightness brightness = Brightness .light,
16+ bool useMaterial3 = false ,
1617}) {
1718 return MaterialApp (
18- theme: ThemeData (brightness: brightness),
19+ theme: ThemeData (brightness: brightness, useMaterial3 : useMaterial3 ),
1920 home: Directionality (
2021 textDirection: textDirection,
2122 child: MediaQuery (
@@ -26,10 +27,14 @@ Widget wrapForChip({
2627 );
2728}
2829
29- Widget selectedInputChip ({ Color ? checkmarkColor }) {
30+ Widget selectedInputChip ({
31+ Color ? checkmarkColor,
32+ bool enabled = false ,
33+ }) {
3034 return InputChip (
3135 label: const Text ('InputChip' ),
3236 selected: true ,
37+ isEnabled: enabled,
3338 showCheckmark: true ,
3439 checkmarkColor: checkmarkColor,
3540 );
@@ -41,9 +46,11 @@ Future<void> pumpCheckmarkChip(
4146 required Widget chip,
4247 Color ? themeColor,
4348 Brightness brightness = Brightness .light,
49+ bool useMaterial3 = false ,
4450}) async {
4551 await tester.pumpWidget (
4652 wrapForChip (
53+ useMaterial3: useMaterial3,
4754 brightness: brightness,
4855 child: Builder (
4956 builder: (BuildContext context) {
@@ -75,6 +82,15 @@ void expectCheckmarkColor(Finder finder, Color color) {
7582 );
7683}
7784
85+ RenderBox getMaterialBox (WidgetTester tester) {
86+ return tester.firstRenderObject <RenderBox >(
87+ find.descendant (
88+ of: find.byType (InputChip ),
89+ matching: find.byType (CustomPaint ),
90+ ),
91+ );
92+ }
93+
7894void checkChipMaterialClipBehavior (WidgetTester tester, Clip clipBehavior) {
7995 final Iterable <Material > materials = tester.widgetList <Material >(find.byType (Material ));
8096 // There should be two Material widgets, first Material is from the "_wrapForChip" and
@@ -238,4 +254,28 @@ void main() {
238254 await tester.pumpWidget (wrapForChip (child: const InputChip (label: label, clipBehavior: Clip .antiAlias)));
239255 checkChipMaterialClipBehavior (tester, Clip .antiAlias);
240256 });
257+
258+ testWidgets ('Input chip has correct selected color when enabled - M3 defaults' , (WidgetTester tester) async {
259+ final ChipThemeData material3ChipDefaults = ThemeData (useMaterial3: true ).chipTheme;
260+ await pumpCheckmarkChip (
261+ tester,
262+ chip: selectedInputChip (enabled: true ),
263+ useMaterial3: true ,
264+ );
265+
266+ final RenderBox materialBox = getMaterialBox (tester);
267+ expect (materialBox, paints..rrect (color: material3ChipDefaults.backgroundColor));
268+ });
269+
270+ testWidgets ('Input chip has correct selected color when disabled - M3 defaults' , (WidgetTester tester) async {
271+ final ChipThemeData material3ChipDefaults = ThemeData (useMaterial3: true ).chipTheme;
272+ await pumpCheckmarkChip (
273+ tester,
274+ chip: selectedInputChip (),
275+ useMaterial3: true ,
276+ );
277+
278+ final RenderBox materialBox = getMaterialBox (tester);
279+ expect (materialBox, paints..path (color: material3ChipDefaults.disabledColor));
280+ });
241281}
0 commit comments