Unverified Commit aa7ab108 authored by xubaolin's avatar xubaolin Committed by GitHub

BorderRadiusTween.lerp supports null begin/end values (#79860)

parent 7aa188ba
...@@ -11,7 +11,7 @@ const double _kFrontClosedHeight = 92.0; // front layer height when closed ...@@ -11,7 +11,7 @@ const double _kFrontClosedHeight = 92.0; // front layer height when closed
const double _kBackAppBarHeight = 56.0; // back layer (options) appbar height const double _kBackAppBarHeight = 56.0; // back layer (options) appbar height
// The size of the front layer heading's left and right beveled corners. // The size of the front layer heading's left and right beveled corners.
final Animatable<BorderRadius> _kFrontHeadingBevelRadius = BorderRadiusTween( final Animatable<BorderRadius?> _kFrontHeadingBevelRadius = BorderRadiusTween(
begin: const BorderRadius.only( begin: const BorderRadius.only(
topLeft: Radius.circular(12.0), topLeft: Radius.circular(12.0),
topRight: Radius.circular(12.0), topRight: Radius.circular(12.0),
...@@ -315,7 +315,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin ...@@ -315,7 +315,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
color: Theme.of(context).canvasColor, color: Theme.of(context).canvasColor,
clipper: ShapeBorderClipper( clipper: ShapeBorderClipper(
shape: BeveledRectangleBorder( shape: BeveledRectangleBorder(
borderRadius: _kFrontHeadingBevelRadius.transform(_controller!.value), borderRadius: _kFrontHeadingBevelRadius.transform(_controller!.value)!,
), ),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
......
...@@ -125,7 +125,7 @@ class EdgeInsetsGeometryTween extends Tween<EdgeInsetsGeometry> { ...@@ -125,7 +125,7 @@ class EdgeInsetsGeometryTween extends Tween<EdgeInsetsGeometry> {
/// [BorderRadius.lerp]. /// [BorderRadius.lerp].
/// ///
/// See [Tween] for a discussion on how to use interpolation objects. /// See [Tween] for a discussion on how to use interpolation objects.
class BorderRadiusTween extends Tween<BorderRadius> { class BorderRadiusTween extends Tween<BorderRadius?> {
/// Creates a [BorderRadius] tween. /// Creates a [BorderRadius] tween.
/// ///
/// The [begin] and [end] properties may be null; the null value /// The [begin] and [end] properties may be null; the null value
...@@ -134,7 +134,7 @@ class BorderRadiusTween extends Tween<BorderRadius> { ...@@ -134,7 +134,7 @@ class BorderRadiusTween extends Tween<BorderRadius> {
/// Returns the value this variable has at the given animation clock value. /// Returns the value this variable has at the given animation clock value.
@override @override
BorderRadius lerp(double t) => BorderRadius.lerp(begin, end, t)!; BorderRadius? lerp(double t) => BorderRadius.lerp(begin, end, t);
} }
/// An interpolation between two [Border]s. /// An interpolation between two [Border]s.
......
...@@ -230,4 +230,11 @@ void main() { ...@@ -230,4 +230,11 @@ void main() {
expect(tween.transform(0.5), 0.31640625); expect(tween.transform(0.5), 0.31640625);
expect(tween.transform(1.0), 1.0); expect(tween.transform(1.0), 1.0);
}); });
test('BorderRadiusTween nullable test', () {
final BorderRadiusTween tween = BorderRadiusTween(begin: null, end: null);
expect(tween.transform(0.0), null);
expect(tween.transform(1.0), null);
expect(tween.lerp(0.0), null);
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment