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

Allows to control the image content alignment. #5

Closed
wants to merge 1 commit into from
Closed

Allows to control the image content alignment. #5

wants to merge 1 commit into from

Conversation

Skyost
Copy link
Contributor

@Skyost Skyost commented Mar 9, 2021

A use case could be when flutter_tex_js is used to render HTML content. For instance :

is more beautiful than :

@amake
Copy link
Owner

amake commented Mar 9, 2021

I presume you have a Column of widgets in your Dart code.

Try setting the crossAxisAlignment to CrossAxisAlignment.start.

@amake
Copy link
Owner

amake commented Mar 10, 2021

Sorry, I now realize that I may not be understanding some nuance of your use case.

Please see this example that illustrates my suggestion above: 46d6b7b

If you remove the crossAxisAlignment: CrossAxisAlignment.start then everything will be centered, but with that setting in place everything correctly justifies to the left.

If that doesn't cover your use case, can you provide some sample code? It sounds like maybe you're using TexImage with the flutter_html package, and somehow that's causing the widget's width to always be as wide as possible?

@Skyost
Copy link
Contributor Author

Skyost commented Mar 10, 2021

In fact, I've already set crossAxisAlignment to start (see code here). I've put flutter_tex_js in a Container, causing the inner image to be as wide as possible (see code here) ; with color set to red :

@amake
Copy link
Owner

amake commented Mar 10, 2021

Thanks for the details and for the links.

I tried reproducing with my example and found that the Container (and its transform) is not the cause of the widening. I think it must be something about how flutter_html lays out its contents.

When I forced a similar situation in my example app by wrapping with a Container(width: double.infinity, ...), I found that wrapping TexImage with Align(alignment: Alignment.centerLeft, child: TexImage(...)) fixed the problem. Does that work for you?

I apologize if it seems like I'm going out of my way to reject your PR. I think it's probably a reasonable addition. My main concern however is that we don't offer a workaround that obscures other, more serious problems with the layout.

@Skyost
Copy link
Contributor Author

Skyost commented Mar 10, 2021

I found that wrapping TexImage with Align(alignment: Alignment.centerLeft, child: TexImage(...)) fixed the problem.

I've already tried to do that :

And the problem is that all math containers go full left :

I apologize if it seems like I'm going out of my way to reject your PR.

Hey no problem, it's your project after all 😄

My main concern however is that we don't offer a workaround that obscures other, more serious problems with the layout.

You may be interested by the widget tree, so here's a part of it :

@amake
Copy link
Owner

amake commented Mar 10, 2021

Right, Align would only be good for the block math elements, not the inline ones.

I note also that you are using displayMode: false for all cases. I think this should only be false for inline elements; is there a reason you're not doing that?

If you can distinguish between block and inline elements then I would recommend using Align and displayMode: true for block elements and your current setup for inline elements.

If you really can't distinguish them, then I guess that right there is the use case for your PR.

@Skyost
Copy link
Contributor Author

Skyost commented Mar 10, 2021

I really can't distinguish them as it's mostly user-generated content written with $ tags only (tags like \[ \] are not allowed). Therefore, all my math elements are inline elements.

@amake
Copy link
Owner

amake commented Mar 10, 2021

OK, thanks for your patience. I made some adjustments.

I'll cut a new release shortly.

@amake amake closed this Mar 10, 2021
@Skyost
Copy link
Contributor Author

Skyost commented Mar 10, 2021

Cool, and thanks for this awesome library ! 😉

@amake
Copy link
Owner

amake commented Mar 10, 2021

This is released as v1.2.0.

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.

None yet

2 participants