Adds dart fixes for Color opacity functions (#154953)

fixes https://github.com/flutter/flutter/issues/154572
This commit is contained in:
gaaclarke 2024-09-10 16:12:56 -07:00 committed by GitHub
parent 1c3b501f53
commit 746d8af006
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 0 deletions

View File

@ -117,4 +117,36 @@ transforms:
- kind: 'rename' - kind: 'rename'
newName: 'fromViewPadding' 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. # Before adding a new fix: read instructions at the top of this file.

View File

@ -18,4 +18,8 @@ void main() {
TextPainter.computeWidth(textScaleFactor: textScaleFactor); TextPainter.computeWidth(textScaleFactor: textScaleFactor);
TextPainter.computeMaxIntrinsicWidth(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);
} }

View File

@ -18,4 +18,8 @@ void main() {
TextPainter.computeWidth(textScaler: TextScaler.linear(textScaleFactor)); TextPainter.computeWidth(textScaler: TextScaler.linear(textScaleFactor));
TextPainter.computeMaxIntrinsicWidth(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);
} }