Skip to content

Commit 3665cfb

Browse files
gaaclarkesfshaza2
andauthored
Adds note about color equality after wide gamut. (#11132)
## _Description of what this PR is changing or adding, and why:_ Adding more details about the changing of Color equality. ## _Issues fixed by this PR (if any):_ flutter/flutter#127855 ## _PRs or commits this PR depends on (if any):_ flutter/engine#54981 ## Presubmit checklist - [x] This PR is marked as draft with an explanation if not meant to land until a future stable release. - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Shams Zakhour (ignore Sfshaza) <[email protected]>
1 parent 489a616 commit 3665cfb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/content/release/breaking-changes/wide-gamut-framework.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,21 @@ final x = color.withOpacity(0.0);
141141
final x = color.withValues(alpha: 0.0);
142142
```
143143

144+
### Equality
145+
146+
Once `Color` stores its color components as floating-point numbers,
147+
equality works slightly differently.
148+
When calculating colors there might be tiny
149+
difference in values that could be considered equal.
150+
To accommodate this use the [`closeTo`][] matcher or the [`isColorSameAs`][] matcher.
151+
152+
```dart
153+
// Before
154+
expect(calculateColor(), const Color(0xffff00ff));
155+
// After
156+
expect(calculateColor(), isSameColorAs(const Color(0xffff00ff)));
157+
```
158+
144159
## Timeline
145160

146161
### Phase 1 - New API introduction, old API deprecation
@@ -168,3 +183,5 @@ Relevant PRs:
168183
[Impeller]: {{site.api}}/perf/impeller
169184
[wide gamut color spaces]: https://en.wikipedia.org/wiki/RGB_color_spaces
170185
[inheritance to composition]: https://en.wikipedia.org/wiki/Composition_over_inheritance
186+
[`closeTo`]: {{site.api}}/documentation/matcher/latest/matcher/closeTo.html
187+
[`isColorSameAs`]: {{site.api}}/flutter/flutter_test/isSameColorAs.html

0 commit comments

Comments
 (0)