Commit 7bfa3c56 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

FlutterLogoDecoration.lerpFrom/lerpTo with non-logos (#12360)

FlutterLogoDecoration should defer to Decoration for what to do when
it doesn't know how to lerp to/from another kind of decoration.
parent ce930db3
...@@ -165,19 +165,21 @@ class FlutterLogoDecoration extends Decoration { ...@@ -165,19 +165,21 @@ class FlutterLogoDecoration extends Decoration {
@override @override
FlutterLogoDecoration lerpFrom(Decoration a, double t) { FlutterLogoDecoration lerpFrom(Decoration a, double t) {
assert(debugAssertIsValid()); assert(debugAssertIsValid());
if (a is! FlutterLogoDecoration) if (a == null || a is FlutterLogoDecoration) {
return lerp(null, this, t); assert(a == null || a.debugAssertIsValid());
assert(a.debugAssertIsValid()); return FlutterLogoDecoration.lerp(a, this, t);
return lerp(a, this, t); }
return super.lerpFrom(a, t);
} }
@override @override
FlutterLogoDecoration lerpTo(Decoration b, double t) { FlutterLogoDecoration lerpTo(Decoration b, double t) {
assert(debugAssertIsValid()); assert(debugAssertIsValid());
if (b is! FlutterLogoDecoration) if (b == null || b is FlutterLogoDecoration) {
return lerp(this, null, t); assert(b == null || b.debugAssertIsValid());
assert(b.debugAssertIsValid()); return FlutterLogoDecoration.lerp(this, b, t);
return lerp(this, b, t); }
return super.lerpTo(b, t);
} }
@override @override
......
...@@ -56,6 +56,11 @@ void main() { ...@@ -56,6 +56,11 @@ void main() {
expect(logo.margin, EdgeInsets.lerp(start.margin, end.margin, 0.5)); expect(logo.margin, EdgeInsets.lerp(start.margin, end.margin, 0.5));
}); });
test('FlutterLogoDecorationl.lerpFrom and FlutterLogoDecorationl.lerpTo', () {
expect(Decoration.lerp(start, const BoxDecoration(), 1.0), const BoxDecoration());
expect(Decoration.lerp(const BoxDecoration(), end, 0.0), end);
});
test('FlutterLogoDecoration lerp changes styles at 0.5', () { test('FlutterLogoDecoration lerp changes styles at 0.5', () {
FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, end, 0.4); FlutterLogoDecoration logo = FlutterLogoDecoration.lerp(start, end, 0.4);
expect(logo.style, start.style); expect(logo.style, start.style);
......
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