max-width attribute and auto-margins on network images for Flutter 3.10
This PR is not ready to be merged. I made it as best as I could while trying to learn the inner workings of this beautiful package :)
- max-width is applied only within the build function of
CssBoxWidget; I have no idea if this is complete or even correct. - The behavior isn't fully coded
- I added
shrinkWrapto network images so they could work with Flutter 3.10, which apparently is the cause of images going out of screen (#1357)
Hopefully, it's not too shabby. The use of shrinkWrap should probably be removed in favor of understanding what's going wrong in the _calculateUsedMargins, but I haven't even tried given shrinkWrap fixes it (by bypassing the issue), at least AFAIK.
- It is necessary to determine whether the current style width is greater than the screen width;
- Keep the aspect ratio of the picture, otherwise the picture will be stretched and distorted
Where used set like this.
This PR is not ready to be merged. I made it as best as I could while trying to learn the inner workings of this beautiful package :)
@TheCarpetMerchant Do you intend to finish it or would you prefer someone to take over?
@eEQK Would prefer someone at least look it over. I didn't even run tests because my local setup kept erroring out ; it just works for my use case as is. If what I did is enough then great, but it would still be better someone take it over, especially to separate the 2 commits which are really two different things.
@eEQK Finally back to it. What's missing for now it the ability to compare 2 Widths that aren't in the same unit, if you know how to do that on a sufficient "best effort" basis at least that'd be great. Since there's now a bunch of commits and this is 2 separate things in one PR (maxWidth and the BoxFit.contain change), I can close this PR and open 2 others if you think it's better for the commit history.
Adding fit: BoxFit.contain, to lib/src/builtins/image_builtin.dart
and using the width property in HTML() as follows:
'img': Style( width: Width( MediaQuery.of(context).size.width, Unit.auto, ), )
This give image width a good size but shows empty white space above and below the image. Something that can be recommended?
'img': Style( width: Width( MediaQuery.of(context).size.width, Unit.auto, ), )
Any update on this issue?
Html(
shrinkWrap: true,
data: widget.content,
onLinkTap: (url, _, __) {
handleLinkTap(url, _, __, _);
},
style: {
"body": Style(
margin: Margins.zero,
padding: HtmlPaddings.symmetric(horizontal: 0),
),
'img': Style(
width: Width(100, Unit.px),
)
}),
unable to render image