diff --git a/packages/flutter/lib/src/painting/shape_decoration.dart b/packages/flutter/lib/src/painting/shape_decoration.dart index 9909128b053..20785bced21 100644 --- a/packages/flutter/lib/src/painting/shape_decoration.dart +++ b/packages/flutter/lib/src/painting/shape_decoration.dart @@ -237,7 +237,7 @@ class ShapeDecoration extends Decoration { return ShapeDecoration( color: Color.lerp(a?.color, b?.color, t), gradient: Gradient.lerp(a?.gradient, b?.gradient, t), - image: t < 0.5 ? a!.image : b!.image, // TODO(ianh): cross-fade the image + image: t < 0.5 ? a?.image : b?.image, // TODO(ianh): cross-fade the image shadows: BoxShadow.lerpList(a?.shadows, b?.shadows, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t)!, ); diff --git a/packages/flutter/test/painting/shape_decoration_test.dart b/packages/flutter/test/painting/shape_decoration_test.dart index 9c6adf10dac..402aa70c3b6 100644 --- a/packages/flutter/test/painting/shape_decoration_test.dart +++ b/packages/flutter/test/painting/shape_decoration_test.dart @@ -48,6 +48,14 @@ void main() { expect(identical(ShapeDecoration.lerp(shape, shape, 0.5), shape), true); }); + test('ShapeDecoration.lerp null a,b', () { + const Decoration a = ShapeDecoration(shape: CircleBorder()); + const Decoration b = ShapeDecoration(shape: RoundedRectangleBorder()); + expect(Decoration.lerp(a, null, 0.0), a); + expect(Decoration.lerp(null, b, 0.0), b); + expect(Decoration.lerp(null, null, 0.0), null); + }); + test('ShapeDecoration.lerp and hit test', () { const Decoration a = ShapeDecoration(shape: CircleBorder()); const Decoration b = ShapeDecoration(shape: RoundedRectangleBorder());