-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
SizedBox
with zero size throws Failed assertion: ... 'width > 0.0': is not true
, Proposal to improve error message if SizedBox
has zero size
#135082
Comments
Thanks for the report. The error occurs due to the fact that the The use case is if we provide 0 values then it throws: Treating the issue as applicable and labeling for team's attention. |
Failed assertion: ... 'width > 0.0': is not true
should provide substantially more information in this error message SizedBox
with zero size throws Failed assertion: ... 'width > 0.0': is not true
, Proposal to improve error message if SizedBox
has zero size
@darshankawar i am new to contribution can i do this change? |
@darshankawar based on my initial research, this issue is not of SizedBox. This issue only happens when the SizedBox is wrapped with FittedBox. FittedBox is a widget that tries to size and position its child within the available space while maintaining the child's aspect ratio (kind of similar to ConstrainedBox). When you set the width and height of the SizedBox child to zero, you are essentially telling Flutter to render a child with zero dimensions, which is causing the error. We need to change the assert message which is present here. |
@AbhishekDoshi26 this is just the case when the view is in a I could also imagine the case that it is in a Edit: Might be the parent size should be not zero in all those cases. |
The same issue persists in this code. |
Would it be the correct for a Or should Also possible work around by wrapping child with |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Is there an existing issue for this?
Steps to reproduce
Expected results
Nothing to be displayed as the widget is effectively zero sized.
Actual results
If I change the SizedBox to have a non-zero size, or take the FittedBox out of the Row, then the assertion goes away. I'm only filing this to improve the error message / handling of zero width elements.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: