Skip to content
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

fix: aspect ratio should never be NaN. #769

Closed

Conversation

SmitSonani
Copy link

In attributes Map, when width & height both are "0", the _aspectRatio function was returning NaN instead some valid ratio.

final heightString = attributes["height"];
final widthString = attributes["width"];
if (heightString != null && widthString != null) {
final height = double.tryParse(heightString);
final width = double.tryParse(widthString);
return height == null || width == null ? calculated.data!.aspectRatio : width / height;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you solution is okay but would it have been enough to just check that height is not 0 and return 1 in that case?

@Sub6Resources
Copy link
Owner

#1222 provides a more clean solution. Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants