diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index d5c647f55a..81a0a89d8c 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -321,7 +321,7 @@ class BoxDecoration extends Decoration { && other.image == image && other.border == border && other.borderRadius == borderRadius - && other.boxShadow == boxShadow + && listEquals(other.boxShadow, boxShadow) && other.gradient == gradient && other.shape == shape; } @@ -333,7 +333,7 @@ class BoxDecoration extends Decoration { image, border, borderRadius, - boxShadow, + hashList(boxShadow), gradient, shape, ); diff --git a/packages/flutter/lib/src/painting/shape_decoration.dart b/packages/flutter/lib/src/painting/shape_decoration.dart index e4e5b1f6af..5138248d4a 100644 --- a/packages/flutter/lib/src/painting/shape_decoration.dart +++ b/packages/flutter/lib/src/painting/shape_decoration.dart @@ -257,7 +257,7 @@ class ShapeDecoration extends Decoration { && other.color == color && other.gradient == gradient && other.image == image - && other.shadows == shadows + && listEquals(other.shadows, shadows) && other.shape == shape; } @@ -268,7 +268,7 @@ class ShapeDecoration extends Decoration { gradient, image, shape, - shadows, + hashList(shadows), ); } diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index 6eded7067e..2cf0dec9ce 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_test.dart @@ -126,6 +126,21 @@ void main() { expect(c.color, equals(b.color)); }); + test('Decoration equality', () { + const BoxDecoration a = BoxDecoration( + color: Color(0xFFFFFFFF), + boxShadow: [BoxShadow()], + ); + + const BoxDecoration b = BoxDecoration( + color: Color(0xFFFFFFFF), + boxShadow: [BoxShadow()], + ); + + expect(a.hashCode, equals(b.hashCode)); + expect(a, equals(b)); + }); + test('BoxDecorationImageListenerSync', () { final ImageProvider imageProvider = SynchronousTestImageProvider(); final DecorationImage backgroundImage = DecorationImage(image: imageProvider); diff --git a/packages/flutter/test/widgets/shape_decoration_test.dart b/packages/flutter/test/widgets/shape_decoration_test.dart index dbfc9ed0c1..de5662d420 100644 --- a/packages/flutter/test/widgets/shape_decoration_test.dart +++ b/packages/flutter/test/widgets/shape_decoration_test.dart @@ -115,4 +115,21 @@ Future main() async { ], ); }); + + test('ShapeDecoration equality', () { + const ShapeDecoration a = ShapeDecoration( + color: Color(0xFFFFFFFF), + shadows: [BoxShadow()], + shape: Border(), + ); + + const ShapeDecoration b = ShapeDecoration( + color: Color(0xFFFFFFFF), + shadows: [BoxShadow()], + shape: Border(), + ); + + expect(a.hashCode, equals(b.hashCode)); + expect(a, equals(b)); + }); }