update BorderTween nullable (#79919)

This commit is contained in:
xubaolin 2021-04-08 00:02:11 +08:00 committed by GitHub
parent 3dbe7f23c5
commit f11b47f7e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -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.

View File

@ -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)));