diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index ddda85d2752..45d62600a84 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -263,7 +263,7 @@ class Color { /// /// A value of 0 means this color is fully transparent. A value of 255 means /// this color is fully opaque. - @Deprecated('Use .a.') + @Deprecated('Use (*.a * 255.0).round() & 0xff') int get alpha => (0xff000000 & value) >> 24; /// The alpha channel of this color as a double. @@ -274,15 +274,15 @@ class Color { double get opacity => alpha / 0xFF; /// The red channel of this color in an 8 bit value. - @Deprecated('Use .r.') + @Deprecated('Use (*.r * 255.0).round() & 0xff') int get red => (0x00ff0000 & value) >> 16; /// The green channel of this color in an 8 bit value. - @Deprecated('Use .g.') + @Deprecated('Use (*.g * 255.0).round() & 0xff') int get green => (0x0000ff00 & value) >> 8; /// The blue channel of this color in an 8 bit value. - @Deprecated('Use .b.') + @Deprecated('Use (*.b * 255.0).round() & 0xff') int get blue => (0x000000ff & value) >> 0; /// Returns a new color with the provided components updated. diff --git a/packages/flutter/lib/fix_data/fix_painting.yaml b/packages/flutter/lib/fix_data/fix_painting.yaml index 0ce947676cb..ea94b3c13fd 100644 --- a/packages/flutter/lib/fix_data/fix_painting.yaml +++ b/packages/flutter/lib/fix_data/fix_painting.yaml @@ -127,6 +127,19 @@ transforms: - kind: 'rename' newName: 'a' + - title: "Replace 'value' with 'toARGB32()'" + date: 2025-02-03 + element: + uris: [ 'painting.dart' ] + method: 'value' + inClass: 'Color' + changes: + - kind: 'replacedBy' + newElement: + uris: [ 'painting.dart' ] + method: 'toARGB32' + inClass: 'Color' + - title: "Rename 'withOpacity'" date: 2024-09-10 element: diff --git a/packages/flutter/test_fixes/painting/painting.dart b/packages/flutter/test_fixes/painting/painting.dart index 1bddb16ff18..efa2246e199 100644 --- a/packages/flutter/test_fixes/painting/painting.dart +++ b/packages/flutter/test_fixes/painting/painting.dart @@ -22,5 +22,6 @@ void main() { Color color = Color.from(alpha: 1, red: 0, green: 1, blue: 0); print(color.opacity); + print(color.value); color = color.withOpacity(0.55); } diff --git a/packages/flutter/test_fixes/painting/painting.dart.expect b/packages/flutter/test_fixes/painting/painting.dart.expect index 33a8f37dcea..816ff5b7915 100644 --- a/packages/flutter/test_fixes/painting/painting.dart.expect +++ b/packages/flutter/test_fixes/painting/painting.dart.expect @@ -21,5 +21,6 @@ void main() { Color color = Color.from(alpha: 1, red: 0, green: 1, blue: 0); print(color.a); + print(color.toARGB32()); color = color.withValues(alpha: 0.55); }