Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ec7315e

Browse files
committed
fixed equality
1 parent d2405aa commit ec7315e

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/ui/painting.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,9 @@ class Color {
455455
if (other.runtimeType != runtimeType) {
456456
return false;
457457
}
458-
return other is Color
459-
&& other.value == value;
458+
return other is Color &&
459+
other.value == value &&
460+
other.colorSpace == colorSpace;
460461
}
461462

462463
@override

lib/web_ui/lib/painting.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ class Color {
247247
if (other.runtimeType != runtimeType) {
248248
return false;
249249
}
250-
return other is Color
251-
&& other.value == value;
250+
return other is Color &&
251+
other.value == value &&
252+
other.colorSpace == colorSpace;
252253
}
253254

254255
@override

testing/dart/color_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ void main() {
301301
expect(srgb.hashCode, notEquals(p3.hashCode));
302302
});
303303

304+
test('equality considers colorspace', () {
305+
const Color srgb = Color.from(
306+
alpha: 1, red: 1, green: 0, blue: 0);
307+
const Color p3 = Color.from(
308+
alpha: 1, red: 1, green: 0, blue: 0, colorSpace: ColorSpace.displayP3);
309+
expect(srgb, notEquals(p3));
310+
});
311+
304312
// Regression test for https://github.com/flutter/flutter/issues/41257
305313
// CupertinoDynamicColor was overriding base class and calling super(0).
306314
test('subclass of Color can override value', () {

0 commit comments

Comments
 (0)