From 25224469b5ad183cf0b3b29ee5892447fedcf79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Tue, 21 Feb 2023 13:27:19 +0100 Subject: [PATCH] fix(ui_components): fix MultiColor lerp method --- .../wyatt_ui_components/lib/src/core/utils/multi_color.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart b/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart index 9e9b7222..d64ac9a3 100644 --- a/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart +++ b/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart @@ -64,12 +64,15 @@ class MultiColor { ); } else if (a.isGradient && b.isGradient) { final colors = List.empty(growable: true); - for (int i = 0; i < a.colors.length; i++) { + final shortestList = + (a.colors.length > b.colors.length) ? b.colors : a.colors; + for (int i = 0; i < shortestList.length; i++) { final lerpColor = Color.lerp(a.colors[i], b.colors[i], t); if (lerpColor != null) { colors.add(lerpColor); } } + return MultiColor(colors); } return b; }