Preserve transform when using *Gradient:withOpacity (#154908)
i don't think it was intentional to lose it? - [] All existing and new tests are passing.
This commit is contained in:
parent
d95821c1d1
commit
27ec9ab982
@ -570,6 +570,7 @@ class LinearGradient extends Gradient {
|
||||
],
|
||||
stops: stops,
|
||||
tileMode: tileMode,
|
||||
transform: transform,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -872,6 +873,7 @@ class RadialGradient extends Gradient {
|
||||
tileMode: tileMode,
|
||||
focal: focal,
|
||||
focalRadius: focalRadius,
|
||||
transform: transform,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1149,6 +1151,7 @@ class SweepGradient extends Gradient {
|
||||
],
|
||||
stops: stops,
|
||||
tileMode: tileMode,
|
||||
transform: transform,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +445,32 @@ void main() {
|
||||
Color(0x80777777),
|
||||
Color(0x80444444),
|
||||
],
|
||||
),);
|
||||
));
|
||||
});
|
||||
|
||||
test('LinearGradient withOpacity() preserves transform', () {
|
||||
const LinearGradient testGradient = LinearGradient(
|
||||
begin: Alignment.bottomRight,
|
||||
end: Alignment.topCenter,
|
||||
colors: <Color>[
|
||||
Color(0xFFFFFFFF),
|
||||
Color(0xAF777777),
|
||||
Color(0x44444444),
|
||||
],
|
||||
transform: GradientRotation(1),
|
||||
);
|
||||
final LinearGradient actual = testGradient.withOpacity(0.5);
|
||||
|
||||
expect(actual, const LinearGradient(
|
||||
begin: Alignment.bottomRight,
|
||||
end: Alignment.topCenter,
|
||||
colors: <Color>[
|
||||
Color(0x80FFFFFF),
|
||||
Color(0x80777777),
|
||||
Color(0x80444444),
|
||||
],
|
||||
transform: GradientRotation(1),
|
||||
));
|
||||
});
|
||||
|
||||
test('RadialGradient with AlignmentDirectional', () {
|
||||
@ -765,6 +790,36 @@ void main() {
|
||||
],
|
||||
));
|
||||
});
|
||||
|
||||
test('RadialGradient withOpacity() preserves transform', () {
|
||||
const RadialGradient testGradient = RadialGradient(
|
||||
center: Alignment.topLeft,
|
||||
focal: Alignment.centerLeft,
|
||||
radius: 20.0,
|
||||
focalRadius: 10.0,
|
||||
colors: <Color>[
|
||||
Color(0xFFFFFFFF),
|
||||
Color(0xAF777777),
|
||||
Color(0x44444444),
|
||||
],
|
||||
transform: GradientRotation(1),
|
||||
);
|
||||
final RadialGradient actual = testGradient.withOpacity(0.5);
|
||||
|
||||
expect(actual, const RadialGradient(
|
||||
center: Alignment.topLeft,
|
||||
focal: Alignment.centerLeft,
|
||||
radius: 20.0,
|
||||
focalRadius: 10.0,
|
||||
colors: <Color>[
|
||||
Color(0x80FFFFFF),
|
||||
Color(0x80777777),
|
||||
Color(0x80444444),
|
||||
],
|
||||
transform: GradientRotation(1),
|
||||
));
|
||||
});
|
||||
|
||||
test('SweepGradient lerp test', () {
|
||||
const SweepGradient testGradient1 = SweepGradient(
|
||||
center: Alignment.topLeft,
|
||||
@ -997,6 +1052,32 @@ void main() {
|
||||
],
|
||||
));
|
||||
});
|
||||
|
||||
test('SweepGradient withOpacity() preserves transform', () {
|
||||
const SweepGradient testGradient = SweepGradient(
|
||||
center: Alignment.topLeft,
|
||||
endAngle: math.pi / 2,
|
||||
colors: <Color>[
|
||||
Color(0xFFFFFFFF),
|
||||
Color(0xAF777777),
|
||||
Color(0x44444444),
|
||||
],
|
||||
transform: GradientRotation(1),
|
||||
);
|
||||
final SweepGradient actual = testGradient.withOpacity(0.5);
|
||||
|
||||
expect(actual, const SweepGradient(
|
||||
center: Alignment.topLeft,
|
||||
endAngle: math.pi / 2,
|
||||
colors: <Color>[
|
||||
Color(0x80FFFFFF),
|
||||
Color(0x80777777),
|
||||
Color(0x80444444),
|
||||
],
|
||||
transform: GradientRotation(1),
|
||||
));
|
||||
});
|
||||
|
||||
test('Gradient lerp test (with RadialGradient)', () {
|
||||
const RadialGradient testGradient1 = RadialGradient(
|
||||
center: Alignment.topLeft,
|
||||
|
Loading…
x
Reference in New Issue
Block a user