-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add ResizeImage.policy #121154
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
Add ResizeImage.policy #121154
Conversation
08896f5 to
39292d5
Compare
dnfield
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 with some doc nits
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.
It'd be nice to be more specific about how the new aspect ratio is applied.
Maybe
output image will have the spedified width and height, with the aspect ratio of the new width and height regardless of whether it matches the intrinsic aspect ratio of the image's width and height.
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.
nit:
This may result in a different aspect ratio than the aspect ratio specified by the target width and height, if for example the height gets clamped downwards but the width does not.
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.
Also, consider mentioning that this is similar to [BoxFit.fill] with consideration for null values on width and height, so setting one of those to null would end up corresponding to [BoxFit.fitWidth] or [BoxFit.fitHeight].
Consider mentioning that the fit member is similar to [BoxFit.contain].
I'm not sure if that would confuse more people or just lead to asking why we don't use BoxFit here, but to me having that linkage helps.
5cbb5cb to
aef56fd
Compare
aef56fd to
86ff3c8
Compare
This adds a new `ResizeImage.policy` property that controls how `ResizeImage` will interpret its `width` and `height` properties. The existing behavior is preserved via `ResizeImagePolicy.exact` (default), but there is now the option to use `ResizeImagePolicy.fit`, which satisfies the use case outlined in #118543. The API doc assets were added in flutter/assets-for-api-docs#209 Fixes #118543
86ff3c8 to
c720d39
Compare
This adds a new
ResizeImage.policyproperty that controls howResizeImagewill interpret itswidthandheightproperties. The existing behavior is preserved viaResizeImagePolicy.exact(default), but there is now the option to useResizeImagePolicy.fit, which satisfies the use case outlined in #118543.The API doc assets were added in flutter/assets-for-api-docs#209
Fixes #118543
Pre-launch Checklist
///).