Skip to content

Commit

Permalink
stream_colors [nfc]: Make StreamColorSwatches.lerp's other non-null…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
chrisbobbe committed Jun 26, 2024
1 parent e57d1c6 commit 60a1774
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/widgets/stream_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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)!;
}


Expand Down

0 comments on commit 60a1774

Please sign in to comment.