@@ -194,8 +194,8 @@ class HSVColor {
194194 ///
195195 /// Values outside of the valid range for each channel will be clamped.
196196 static HSVColor ? lerp (HSVColor ? a, HSVColor ? b, double t) {
197- if (a == null && b == null ) {
198- return null ;
197+ if (identical (a, b) ) {
198+ return a ;
199199 }
200200 if (a == null ) {
201201 return b! ._scaleAlpha (t);
@@ -377,8 +377,8 @@ class HSLColor {
377377 /// Values for `t` are usually obtained from an [Animation<double>] , such as
378378 /// an [AnimationController] .
379379 static HSLColor ? lerp (HSLColor ? a, HSLColor ? b, double t) {
380- if (a == null && b == null ) {
381- return null ;
380+ if (identical (a, b) ) {
381+ return a ;
382382 }
383383 if (a == null ) {
384384 return b! ._scaleAlpha (t);
@@ -479,13 +479,12 @@ class ColorSwatch<T> extends Color {
479479 /// Values for `t` are usually obtained from an [Animation<double>] , such as
480480 /// an [AnimationController] .
481481 static ColorSwatch <T >? lerp <T >(ColorSwatch <T >? a, ColorSwatch <T >? b, double t) {
482+ if (identical (a, b)) {
483+ return a;
484+ }
482485 final Map <T , Color > swatch;
483486 if (b == null ) {
484- if (a == null ) {
485- return null ;
486- } else {
487- swatch = a._swatch.map ((T key, Color color) => MapEntry <T , Color >(key, Color .lerp (color, null , t)! ));
488- }
487+ swatch = a! ._swatch.map ((T key, Color color) => MapEntry <T , Color >(key, Color .lerp (color, null , t)! ));
489488 } else {
490489 if (a == null ) {
491490 swatch = b._swatch.map ((T key, Color color) => MapEntry <T , Color >(key, Color .lerp (null , color, t)! ));
0 commit comments