Skip to content

Commit 746d8af

Browse files
authored
Adds dart fixes for Color opacity functions (flutter#154953)
fixes flutter#154572
1 parent 1c3b501 commit 746d8af

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

packages/flutter/lib/fix_data/fix_painting.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,36 @@ transforms:
117117
- kind: 'rename'
118118
newName: 'fromViewPadding'
119119

120+
- title: "Rename from 'opacity' to 'a'"
121+
date: 2024-09-10
122+
element:
123+
uris: [ 'painting.dart' ]
124+
method: 'opacity'
125+
inClass: 'Color'
126+
changes:
127+
- kind: 'rename'
128+
newName: 'a'
129+
130+
- title: "Rename 'withOpacity'"
131+
date: 2024-09-10
132+
element:
133+
uris: [ 'painting.dart' ]
134+
method: 'withOpacity'
135+
inClass: 'Color'
136+
changes:
137+
- kind: 'rename'
138+
newName: 'withValues'
139+
- kind: 'removeParameter'
140+
index: 0
141+
- kind: 'addParameter'
142+
index: 0
143+
name: 'alpha'
144+
style: optional_named
145+
argumentValue:
146+
expression: '{% opacity %}'
147+
requiredIf: "opacity != ''"
148+
variables:
149+
opacity:
150+
kind: 'fragment'
151+
value: 'arguments[0]'
120152
# Before adding a new fix: read instructions at the top of this file.

packages/flutter/test_fixes/painting/painting.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ void main() {
1818

1919
TextPainter.computeWidth(textScaleFactor: textScaleFactor);
2020
TextPainter.computeMaxIntrinsicWidth(textScaleFactor: textScaleFactor);
21+
22+
Color color = Color.from(alpha: 1, red: 0, green: 1, blue: 0);
23+
print(color.opacity);
24+
color = color.withOpacity(0.55);
2125
}

packages/flutter/test_fixes/painting/painting.dart.expect

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ void main() {
1818

1919
TextPainter.computeWidth(textScaler: TextScaler.linear(textScaleFactor));
2020
TextPainter.computeMaxIntrinsicWidth(textScaler: TextScaler.linear(textScaleFactor));
21+
22+
Color color = Color.from(alpha: 1, red: 0, green: 1, blue: 0);
23+
print(color.a);
24+
color = color.withValues(alpha: 0.55);
2125
}

0 commit comments

Comments
 (0)