From 7eeafb1287c5fc05311fcb75786849371bf36531 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 25 Mar 2022 16:50:15 -0700 Subject: [PATCH] Consider backgroundBlendMode in equality of BoxDecoration (#100788) --- .../flutter/lib/src/painting/box_decoration.dart | 2 ++ .../flutter/test/painting/box_decoration_test.dart | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index 05fe1a4032..86e17df3d8 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -320,6 +320,7 @@ class BoxDecoration extends Decoration { && other.borderRadius == borderRadius && listEquals(other.boxShadow, boxShadow) && other.gradient == gradient + && other.backgroundBlendMode == backgroundBlendMode && other.shape == shape; } @@ -331,6 +332,7 @@ class BoxDecoration extends Decoration { borderRadius, boxShadow == null ? null : Object.hashAll(boxShadow!), gradient, + backgroundBlendMode, shape, ); diff --git a/packages/flutter/test/painting/box_decoration_test.dart b/packages/flutter/test/painting/box_decoration_test.dart index 936e57327e..3c9d557859 100644 --- a/packages/flutter/test/painting/box_decoration_test.dart +++ b/packages/flutter/test/painting/box_decoration_test.dart @@ -95,4 +95,17 @@ void main() { ); expect(clipPath, isLookLikeExpectedPath); }); + + test('BoxDecorations with different blendModes are not equal', () { + // Regression test for https://github.com/flutter/flutter/issues/100754. + const BoxDecoration one = BoxDecoration( + color: Color(0x00000000), + backgroundBlendMode: BlendMode.color, + ); + const BoxDecoration two = BoxDecoration( + color: Color(0x00000000), + backgroundBlendMode: BlendMode.difference, + ); + expect(one == two, isFalse); + }); }