Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds note about color equality after wide gamut. #11132

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Adds note about color equality after wide gamut.
gaaclarke committed Sep 12, 2024
commit 5bca9f9e385a808bc11be3ddd83ded03c15f4847
16 changes: 16 additions & 0 deletions src/content/release/breaking-changes/wide-gamut-framework.md
Original file line number Diff line number Diff line change
@@ -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