-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Make sure that a DecoratedBox doesn't crash in 0x0 environment #180329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure that a DecoratedBox doesn't crash in 0x0 environment #180329
Conversation
There was a problem hiding this 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 for an issue where DecoratedBox crashes when it has a zero size and a gradient. While the test case is a good addition, its current implementation with an empty BoxDecoration does not trigger the crash condition. I've provided a suggestion to include a gradient in the decoration to ensure the test correctly covers the scenario from issue #6537. The fix for the underlying crash itself appears to be missing from this PR.
| const Directionality( | ||
| textDirection: TextDirection.ltr, | ||
| child: Center( | ||
| child: SizedBox.shrink(child: DecoratedBox(decoration: BoxDecoration())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current test setup with an empty BoxDecoration() doesn't trigger the crash condition reported in issue #6537. The crash occurs when a gradient is present on a zero-sized DecoratedBox. To properly test for this scenario, you should add a gradient to the BoxDecoration.
child: SizedBox.shrink(child: DecoratedBox(decoration: BoxDecoration(gradient: LinearGradient(begin: Alignment.topLeft, end: Alignment.bottomRight, colors: <Color>[Color(0xFF000000), Color(0xFFFFFFFF)])))),
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This is my attempt to handle #6537 for the DecoratedBox widget.