From 5bca9f9e385a808bc11be3ddd83ded03c15f4847 Mon Sep 17 00:00:00 2001 From: Aaron Clarke Date: Thu, 12 Sep 2024 14:36:17 -0700 Subject: [PATCH 1/2] Adds note about color equality after wide gamut. --- .../breaking-changes/wide-gamut-framework.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/content/release/breaking-changes/wide-gamut-framework.md b/src/content/release/breaking-changes/wide-gamut-framework.md index 9aa38d3a3d9..0b9095e92c8 100644 --- a/src/content/release/breaking-changes/wide-gamut-framework.md +++ b/src/content/release/breaking-changes/wide-gamut-framework.md @@ -141,6 +141,20 @@ final x = color.withOpacity(0.0); final x = color.withValues(alpha: 0.0); ``` +### Equality + +Now that Color will be storing its color components as floating-point numbers +equality will work slightly different. When calculating colors there may be tiny +difference in numbers which could be considered equal. To accommodate this use +the [`closeTo`][] matcher or the [`isColorSameAs`][] matcher. + +```dart +// Before +expect(calculateColor(), const Color(0xffff00ff)); +// After +expect(calculateColor(), isSameColorAs(const Color(0xffff00ff))); +``` + ## Timeline ### Phase 1 - New API introduction, old API deprecation @@ -168,3 +182,5 @@ Relevant PRs: [Impeller]: {{site.api}}/perf/impeller [wide gamut color spaces]: https://en.wikipedia.org/wiki/RGB_color_spaces [inheritance to composition]: https://en.wikipedia.org/wiki/Composition_over_inheritance +[`closeTo`]: {{site.api}}/documentation/matcher/latest/matcher/closeTo.html +[`isColorSameAs`]: {{site.api}}/flutter/flutter_test/isSameColorAs.html From f2ff5d0fe4760adcbba0d0365d5bb0924f30eadb Mon Sep 17 00:00:00 2001 From: "Shams Zakhour (ignore Sfshaza)" <44418985+sfshaza2@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:55:31 -0700 Subject: [PATCH 2/2] Update src/content/release/breaking-changes/wide-gamut-framework.md --- .../release/breaking-changes/wide-gamut-framework.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/content/release/breaking-changes/wide-gamut-framework.md b/src/content/release/breaking-changes/wide-gamut-framework.md index 0b9095e92c8..5abc118b64b 100644 --- a/src/content/release/breaking-changes/wide-gamut-framework.md +++ b/src/content/release/breaking-changes/wide-gamut-framework.md @@ -143,10 +143,11 @@ final x = color.withValues(alpha: 0.0); ### Equality -Now that Color will be storing its color components as floating-point numbers -equality will work slightly different. When calculating colors there may be tiny -difference in numbers which could be considered equal. To accommodate this use -the [`closeTo`][] matcher or the [`isColorSameAs`][] matcher. +Once `Color` stores its color components as floating-point numbers, +equality works slightly differently. +When calculating colors there might be tiny +difference in values that could be considered equal. +To accommodate this use the [`closeTo`][] matcher or the [`isColorSameAs`][] matcher. ```dart // Before