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

Support Flutter Web #6

Open
giacomoran opened this issue Apr 20, 2021 · 6 comments
Open

Support Flutter Web #6

giacomoran opened this issue Apr 20, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@giacomoran
Copy link

Hi,

Thanks for the great work!

Are there any plans to support Flutter Web?
Otherwise, is there any suggested workaround?

@amake
Copy link
Owner

amake commented Apr 20, 2021

I guess in principle it should be possible to support web as well, since the underlying engine is JavaScript. But it wasn't straightforward when I looked into it last time, and web support isn't something that I personally need, so it's not really on my radar.

Sorry, I don't know if there are any workarounds.

@amake amake added the enhancement New feature or request label Apr 20, 2021
@amake
Copy link
Owner

amake commented Apr 21, 2021

I'm not sure how this would even work since KaTeX can't render to bitmap or canvas (see KaTeX/KaTeX#328, KaTeX/KaTeX#504), or any other source of bytes: it renders to DOM elements, which I don't think would work at all with Flutter widgets.

Maybe it would be doable by adding yet another package like html2canvas to render the KaTeX output to bitmap. But that's a lot of indirection and is pretty far over my head.

@amake
Copy link
Owner

amake commented Apr 21, 2021

Maybe I spoke too soon; this looks like it might be similar to what we want: https://stackoverflow.com/questions/60276170/use-js-library-in-flutter-web

@giacomoran
Copy link
Author

That looks good, thanks!

@amake
Copy link
Owner

amake commented Apr 22, 2021

I got it sort of working:

image

The main issue is that the HtmlElementView widget has infinite width (and height?) so it will blow up your layout. I can't find a way to make it shrink to fit its content; in the screenshot above I've wrapped every instance in a 200×200 SizedBox.

This is about as far as I'm interested in working on this. If someone else wants to swoop in and let me know how to address the layout issue, I'm all ears. The code is on the web branch.

@amake
Copy link
Owner

amake commented Mar 6, 2022

I have migrated the plugin to the federated architecture, so if someone does manage to implement a web version they can more easily use it.

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

No branches or pull requests

2 participants