diff --git a/packages/flutter/lib/fix_data/fix_painting.yaml b/packages/flutter/lib/fix_data/fix_painting.yaml index c8a81381df..0ce947676c 100644 --- a/packages/flutter/lib/fix_data/fix_painting.yaml +++ b/packages/flutter/lib/fix_data/fix_painting.yaml @@ -117,4 +117,36 @@ transforms: - kind: 'rename' newName: 'fromViewPadding' + - title: "Rename from 'opacity' to 'a'" + date: 2024-09-10 + element: + uris: [ 'painting.dart' ] + method: 'opacity' + inClass: 'Color' + changes: + - kind: 'rename' + newName: 'a' + + - title: "Rename 'withOpacity'" + date: 2024-09-10 + element: + uris: [ 'painting.dart' ] + method: 'withOpacity' + inClass: 'Color' + changes: + - kind: 'rename' + newName: 'withValues' + - kind: 'removeParameter' + index: 0 + - kind: 'addParameter' + index: 0 + name: 'alpha' + style: optional_named + argumentValue: + expression: '{% opacity %}' + requiredIf: "opacity != ''" + variables: + opacity: + kind: 'fragment' + value: 'arguments[0]' # Before adding a new fix: read instructions at the top of this file. diff --git a/packages/flutter/test_fixes/painting/painting.dart b/packages/flutter/test_fixes/painting/painting.dart index 2f2669f355..6314117dc1 100644 --- a/packages/flutter/test_fixes/painting/painting.dart +++ b/packages/flutter/test_fixes/painting/painting.dart @@ -18,4 +18,8 @@ void main() { TextPainter.computeWidth(textScaleFactor: textScaleFactor); TextPainter.computeMaxIntrinsicWidth(textScaleFactor: textScaleFactor); + + Color color = Color.from(alpha: 1, red: 0, green: 1, blue: 0); + print(color.opacity); + 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 249f3dac39..33a8f37dce 100644 --- a/packages/flutter/test_fixes/painting/painting.dart.expect +++ b/packages/flutter/test_fixes/painting/painting.dart.expect @@ -18,4 +18,8 @@ void main() { TextPainter.computeWidth(textScaler: TextScaler.linear(textScaleFactor)); TextPainter.computeMaxIntrinsicWidth(textScaler: TextScaler.linear(textScaleFactor)); + + Color color = Color.from(alpha: 1, red: 0, green: 1, blue: 0); + print(color.a); + color = color.withValues(alpha: 0.55); }