@@ -57,7 +57,7 @@ dynamic getRenderChip(WidgetTester tester) {
5757 if (! tester.any (findRenderChipElement ())) {
5858 return null ;
5959 }
60- final Element element = tester.element (findRenderChipElement ());
60+ final Element element = tester.element (findRenderChipElement ().first );
6161 return element.renderObject;
6262}
6363
@@ -3284,6 +3284,55 @@ void main() {
32843284
32853285 expect (tester.takeException (), isNull);
32863286 });
3287+
3288+ testWidgets ('Chip background color and shape are drawn on Ink' , (WidgetTester tester) async {
3289+ const Color backgroundColor = Color (0xff00ff00 );
3290+ const OutlinedBorder shape = ContinuousRectangleBorder ();
3291+
3292+ await tester.pumpWidget (wrapForChip (
3293+ child: const RawChip (
3294+ label: Text ('text' ),
3295+ backgroundColor: backgroundColor,
3296+ shape: shape,
3297+ ),
3298+ ));
3299+
3300+ final Ink ink = tester.widget (find.descendant (
3301+ of: find.byType (RawChip ),
3302+ matching: find.byType (Ink ),
3303+ ));
3304+ final ShapeDecoration decoration = ink.decoration! as ShapeDecoration ;
3305+ expect (decoration.color, backgroundColor);
3306+ expect (decoration.shape, shape);
3307+ });
3308+
3309+ testWidgets ('Chip highlight color is drawn on top of the backgroundColor' , (WidgetTester tester) async {
3310+ final FocusNode focusNode = FocusNode (debugLabel: 'RawChip' );
3311+ tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy .alwaysTraditional;
3312+ const Color backgroundColor = Color (0xff00ff00 );
3313+
3314+ await tester.pumpWidget (wrapForChip (
3315+ child: RawChip (
3316+ label: const Text ('text' ),
3317+ backgroundColor: backgroundColor,
3318+ autofocus: true ,
3319+ focusNode: focusNode,
3320+ onPressed: () {},
3321+ ),
3322+ ));
3323+
3324+ await tester.pumpAndSettle ();
3325+
3326+ expect (focusNode.hasPrimaryFocus, isTrue);
3327+ expect (
3328+ find.byType (Material ).last,
3329+ paints
3330+ // Background color is drawn first.
3331+ ..rrect (color: backgroundColor)
3332+ // Highlight color is drawn on top of the background color.
3333+ ..rect (color: const Color (0x1f000000 )),
3334+ );
3335+ });
32873336}
32883337
32893338class _MaterialStateOutlinedBorder extends StadiumBorder implements MaterialStateOutlinedBorder {
0 commit comments