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

update BorderTween nullable (#79919)

parent 3dbe7f23
...@@ -152,11 +152,7 @@ class BorderTween extends Tween<Border?> { ...@@ -152,11 +152,7 @@ class BorderTween extends Tween<Border?> {
/// 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
Border? lerp(double t) { Border? lerp(double t) => Border.lerp(begin, end, t);
if (begin == null || end == null)
return t < 0.5 ? begin : end;
return Border.lerp(begin!, end!, t);
}
} }
/// An interpolation between two [Matrix4]s. /// An interpolation between two [Matrix4]s.
......
...@@ -139,6 +139,17 @@ void main() { ...@@ -139,6 +139,17 @@ void main() {
expect(animation.toStringDetails(), hasOneLineDescription); expect(animation.toStringDetails(), hasOneLineDescription);
}); });
test('BorderTween nullable test', () {
BorderTween tween = BorderTween();
expect(tween.lerp(0.0), null);
expect(tween.lerp(1.0), null);
tween = BorderTween(begin: null, end: const Border(top: BorderSide()));
expect(tween.lerp(0.0), const Border());
expect(tween.lerp(0.5), const Border(top: BorderSide(width: 0.5)));
expect(tween.lerp(1.0), const Border(top: BorderSide()));
});
test('SizeTween', () { test('SizeTween', () {
final SizeTween tween = SizeTween(begin: Size.zero, end: const Size(20.0, 30.0)); final SizeTween tween = SizeTween(begin: Size.zero, end: const Size(20.0, 30.0));
expect(tween.lerp(0.5), equals(const Size(10.0, 15.0))); expect(tween.lerp(0.5), equals(const Size(10.0, 15.0)));
......
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