Unverified Commit fdf8627c authored by Marcel Kirchhoff's avatar Marcel Kirchhoff Committed by GitHub

Fix VisualDensity's vertical lerp implementation (#96597)

Fixes #96591
parent 219bcd32
...@@ -2592,7 +2592,7 @@ class VisualDensity with Diagnosticable { ...@@ -2592,7 +2592,7 @@ class VisualDensity with Diagnosticable {
static VisualDensity lerp(VisualDensity a, VisualDensity b, double t) { static VisualDensity lerp(VisualDensity a, VisualDensity b, double t) {
return VisualDensity( return VisualDensity(
horizontal: lerpDouble(a.horizontal, b.horizontal, t)!, horizontal: lerpDouble(a.horizontal, b.horizontal, t)!,
vertical: lerpDouble(a.horizontal, b.horizontal, t)!, vertical: lerpDouble(a.vertical, b.vertical, t)!,
); );
} }
......
...@@ -220,4 +220,21 @@ void main() { ...@@ -220,4 +220,21 @@ void main() {
expect(lerped.labelMedium, null); expect(lerped.labelMedium, null);
expect(lerped.labelSmall, null); expect(lerped.labelSmall, null);
}); });
test('VisualDensity.lerp', () {
const VisualDensity a = VisualDensity(horizontal: 1.0, vertical: .5);
const VisualDensity b = VisualDensity(horizontal: 2.0, vertical: 1.0);
final VisualDensity noLerp = VisualDensity.lerp(a, b, 0.0);
expect(noLerp.horizontal, 1.0);
expect(noLerp.vertical, .5);
final VisualDensity quarterLerp = VisualDensity.lerp(a, b, .25);
expect(quarterLerp.horizontal, 1.25);
expect(quarterLerp.vertical, .625);
final VisualDensity fullLerp = VisualDensity.lerp(a, b, 1.0);
expect(fullLerp.horizontal, 2.0);
expect(fullLerp.vertical, 1.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