From 9e2746c13738bf3b9fa96b323d8fb86261354aa3 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:41:08 -0700 Subject: [PATCH] updated Color docstring to address equality (flutter/engine#55496) issue: https://github.com/flutter/flutter/issues/155803 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- engine/src/flutter/lib/ui/painting.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index 09ef1c5e8a..3b683dcbc9 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -78,10 +78,17 @@ Color _scaleAlpha(Color x, double factor) { /// Color c2 = const Color(0xFFFFFFFF); // fully opaque white (visible) /// ``` /// +/// [Color]'s color components are stored as floating-point values. Care should +/// be taken if one does not want the literal equality provided by `operator==`. +/// To test equality inside of Flutter tests consider using `package:test`'s +/// `isSameColorAs`. +/// /// See also: /// -/// * [Colors](https://api.flutter.dev/flutter/material/Colors-class.html), which -/// defines the colors found in the Material Design specification. +/// * [Colors](https://api.flutter.dev/flutter/material/Colors-class.html), +/// which defines the colors found in the Material Design specification. +/// * [`isSameColorAs`](https://api.flutter.dev/flutter/flutter_test/isSameColorAs.html), +/// a Matcher to handle floating-point deltas when checking [Color] equality. class Color { /// Construct an sRGB color from the lower 32 bits of an [int]. ///