Skip to content

Conversation

@ahmedsameha1
Copy link
Contributor

This is my attempt to handle #6537 for the AnimatedGrid widget.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Dec 20, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a regression test to ensure that AnimatedGrid does not crash when rendered in a zero-sized environment. My review points out that the test may not be correctly targeting the scenario described in the associated issue, as it uses a different grid delegate. I've suggested a change to align the test with the original problem.

child: AnimatedGrid(
controller: controller,
itemBuilder: (_, int index, _) => Text('$index'),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The issue this PR aims to fix is specific to SliverGridDelegateWithMaxCrossAxisExtent, which can compute a crossAxisCount of 0 when the available crossAxisExtent is 0, leading to a division by zero. This test uses SliverGridDelegateWithFixedCrossAxisCount, which has a fixed crossAxisCount and doesn't trigger the bug. To properly test the fix, you should use SliverGridDelegateWithMaxCrossAxisExtent.

Suggested change
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2),
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: 150.0),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant