From 60a17741bb7a2be512a508557e4d5d633333ee1f Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 21 Jun 2024 16:22:46 -0700 Subject: [PATCH] stream_colors [nfc]: Make StreamColorSwatches.lerp's `other` non-nullable --- lib/widgets/stream_colors.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/widgets/stream_colors.dart b/lib/widgets/stream_colors.dart index 9435b9cb1e..3686b0cf29 100644 --- a/lib/widgets/stream_colors.dart +++ b/lib/widgets/stream_colors.dart @@ -33,15 +33,13 @@ abstract class StreamColorSwatches { /// This computation is cached on the instance /// in order to save work building [t]'s animation frame when there are /// multiple UI elements using the same [subscription.color]. - StreamColorSwatches lerp(StreamColorSwatches? other, double t) { + StreamColorSwatches lerp(StreamColorSwatches other, double t) { // This short-circuit helps when [a] and [b] // are both [StreamColorSwatches.light] // or both [StreamColorSwatches.dark]. // Empirically, [lerp] is called even when the theme hasn't changed, // so this is an important optimization. - if (identical(this, other)) { - return this; - } + if (identical(this, other)) return this; return _StreamColorSwatchesLerped(this, other, t); } @@ -65,12 +63,12 @@ class _StreamColorSwatchesLerped extends StreamColorSwatches { _StreamColorSwatchesLerped(this.a, this.b, this.t); final StreamColorSwatches a; - final StreamColorSwatches? b; + final StreamColorSwatches b; final double t; @override StreamColorSwatch _computeForBaseColor(int base) => - StreamColorSwatch.lerp(a.forBaseColor(base), b?.forBaseColor(base), t)!; + StreamColorSwatch.lerp(a.forBaseColor(base), b.forBaseColor(base), t)!; }