Fix/decoration equality (#61551)

This commit is contained in:
Bogdan Lukin
2020-07-17 01:26:04 +07:00
committed by GitHub
parent 63ceeb8f15
commit 9ef8192760
4 changed files with 36 additions and 4 deletions

View File

@@ -321,7 +321,7 @@ class BoxDecoration extends Decoration {
&& other.image == image
&& other.border == border
&& other.borderRadius == borderRadius
&& other.boxShadow == boxShadow
&& listEquals<BoxShadow>(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,
);

View File

@@ -257,7 +257,7 @@ class ShapeDecoration extends Decoration {
&& other.color == color
&& other.gradient == gradient
&& other.image == image
&& other.shadows == shadows
&& listEquals<BoxShadow>(other.shadows, shadows)
&& other.shape == shape;
}
@@ -268,7 +268,7 @@ class ShapeDecoration extends Decoration {
gradient,
image,
shape,
shadows,
hashList(shadows),
);
}

View File

@@ -126,6 +126,21 @@ void main() {
expect(c.color, equals(b.color));
});
test('Decoration equality', () {
const BoxDecoration a = BoxDecoration(
color: Color(0xFFFFFFFF),
boxShadow: <BoxShadow>[BoxShadow()],
);
const BoxDecoration b = BoxDecoration(
color: Color(0xFFFFFFFF),
boxShadow: <BoxShadow>[BoxShadow()],
);
expect(a.hashCode, equals(b.hashCode));
expect(a, equals(b));
});
test('BoxDecorationImageListenerSync', () {
final ImageProvider imageProvider = SynchronousTestImageProvider();
final DecorationImage backgroundImage = DecorationImage(image: imageProvider);

View File

@@ -115,4 +115,21 @@ Future<void> main() async {
],
);
});
test('ShapeDecoration equality', () {
const ShapeDecoration a = ShapeDecoration(
color: Color(0xFFFFFFFF),
shadows: <BoxShadow>[BoxShadow()],
shape: Border(),
);
const ShapeDecoration b = ShapeDecoration(
color: Color(0xFFFFFFFF),
shadows: <BoxShadow>[BoxShadow()],
shape: Border(),
);
expect(a.hashCode, equals(b.hashCode));
expect(a, equals(b));
});
}