From cdbe2cd871821a7235d752061c69745997314181 Mon Sep 17 00:00:00 2001 From: lowrt Date: Thu, 4 Dec 2025 20:22:03 +0800 Subject: [PATCH] fix(forecast_card): prevent crash from invalid clamp range in temperature indicator The temperature indicator positioning was causing crashes with 'Invalid argument(s): 0.0' when barWidth - indicatorWidth resulted in an invalid clamp range. Fixed by calculating maxLeft with proper bounds using double.infinity. Fixes Firebase Crashlytics error: Invalid argument(s): 0.0 Co-authored-by: Lingling --- lib/app/home/_widgets/forecast_card.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/app/home/_widgets/forecast_card.dart b/lib/app/home/_widgets/forecast_card.dart index 1b80d2148..dffef45c4 100644 --- a/lib/app/home/_widgets/forecast_card.dart +++ b/lib/app/home/_widgets/forecast_card.dart @@ -325,6 +325,8 @@ class _ForecastCardState extends State { final barWidth = constraints.maxWidth; final indicatorPosition = tempPercent * barWidth; final indicatorWidth = 20.0; + final maxLeft = (barWidth - indicatorWidth).clamp(0.0, double.infinity); + final leftPos = (indicatorPosition - indicatorWidth / 2).clamp(0.0, maxLeft); return Container( height: 20, @@ -335,10 +337,7 @@ class _ForecastCardState extends State { child: Stack( children: [ Positioned( - left: (indicatorPosition - indicatorWidth / 2).clamp( - 0.0, - barWidth - indicatorWidth, - ), + left: leftPos, width: indicatorWidth, height: 20, child: Container(