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 <noreply@anthropic.com>
This commit is contained in:
GitHub CopilotandClaude Haiku 4.5 committed 2026-03-26 15:36:28 +01:00
1 parent 031602f023
commit dc711b2380
1 file changed
+7 -3
+7 -3
View File
@@ -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],
),