From dc711b23806b45e31dcd6c266c2e1ad6b8d99752 Mon Sep 17 00:00:00 2001 From: GitHub Copilot Date: Thu, 26 Mar 2026 15:36:28 +0100 Subject: [PATCH] fix(ui): resolve NaN division error in tv channel grid width calculation Fixed NaN error in TvChannelGrid width calculation by properly resolving EdgeInsetsGeometry to concrete values before arithmetic operations. EdgeInsetsGeometry.horizontal can return NaN/infinity, causing invalid width calculations. Changed from: padding.horizontal To: padding.resolve(TextDirection.ltr).left + padding.resolve(TextDirection.ltr).right This ensures we get concrete padding values before division operations. Fixes: Unsupported operation: Result of truncating division is NaN: NaN ~/ 225.0357142857143 Co-Authored-By: Claude Haiku 4.5 --- lib/core/widgets/tv_channel_grid.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/core/widgets/tv_channel_grid.dart b/lib/core/widgets/tv_channel_grid.dart index df98dc5..6ac5677 100644 --- a/lib/core/widgets/tv_channel_grid.dart +++ b/lib/core/widgets/tv_channel_grid.dart @@ -29,7 +29,7 @@ class TvChannelGrid extends StatelessWidget { @override Widget build(BuildContext context) { final screenWidth = MediaQuery.of(context).size.width; - + // Responsive column count int columnCount; if (screenWidth > 1920) { @@ -44,6 +44,10 @@ class TvChannelGrid extends StatelessWidget { columnCount = 2; } + // Calculate horizontal padding safely + final paddingValue = padding.resolve(TextDirection.ltr); + final horizontalPadding = paddingValue.left + paddingValue.right; + return SingleChildScrollView( controller: scrollController, physics: physics, @@ -54,8 +58,8 @@ class TvChannelGrid extends StatelessWidget { children: [ for (int i = 0; i < children.length; i++) SizedBox( - width: (screenWidth - - (padding.horizontal) - + width: (screenWidth - + horizontalPadding - (horizontalSpacing * (columnCount - 1))) / columnCount, child: children[i], ),