Skip to content

Commit 28ca523

Browse files
authored
Remove incorrect non-nullable assumption from ShapeDecoration.lerp (#129298)
Fixes flutter/flutter#129299
1 parent 16eb4f2 commit 28ca523

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/flutter/lib/src/painting/shape_decoration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class ShapeDecoration extends Decoration {
237237
return ShapeDecoration(
238238
color: Color.lerp(a?.color, b?.color, t),
239239
gradient: Gradient.lerp(a?.gradient, b?.gradient, t),
240-
image: t < 0.5 ? a!.image : b!.image, // TODO(ianh): cross-fade the image
240+
image: t < 0.5 ? a?.image : b?.image, // TODO(ianh): cross-fade the image
241241
shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t),
242242
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)!,
243243
);

packages/flutter/test/painting/shape_decoration_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ void main() {
4848
expect(identical(ShapeDecoration.lerp(shape, shape, 0.5), shape), true);
4949
});
5050

51+
test('ShapeDecoration.lerp null a,b', () {
52+
const Decoration a = ShapeDecoration(shape: CircleBorder());
53+
const Decoration b = ShapeDecoration(shape: RoundedRectangleBorder());
54+
expect(Decoration.lerp(a, null, 0.0), a);
55+
expect(Decoration.lerp(null, b, 0.0), b);
56+
expect(Decoration.lerp(null, null, 0.0), null);
57+
});
58+
5159
test('ShapeDecoration.lerp and hit test', () {
5260
const Decoration a = ShapeDecoration(shape: CircleBorder());
5361
const Decoration b = ShapeDecoration(shape: RoundedRectangleBorder());

0 commit comments

Comments
 (0)