reactjsflutterwidgetflutter-webcodebase

Use flutter web widgets inside a react js app


I have this project where I have to code a website and ios and android apps.

I have to do this with a very limited team (basically myself). So I want to share as much code between those platforms, to avoid maintaining different codebases as much as possible.

I have come to consider flutter : the logic (and interaction with the backend) in dart can be compiled to both ios and android, and to javascript for the web site to call. I also like how the UI is built using flutter.

For the web site, I know there is flutter web that can be used to do a web app, but I want my website to feel like a web site more than a single page app. I have thought about using React+Gatsby to do the website's ui, while calling the dart compiled js for the logic. That would enable high page loading speed, good seo, while keeping the interactivity of a react app and the single codebase logic through dart to js compilation.

I am wondering if this seems like a good approach to you, and if not, how you would do it.

In this approach, I am wondering if it would be possible to embedded flutter web widgets inside of react js components, always in a concern of maintaining as low platform specific code as possible. I have not found any other way of doing this than embedding them into iframes, which does not seem like a good idea, or does it ?


Solution

  • Update

    Flutter Web is now available in a stable version for production.

    enter image description here

    Below answer is relevant back to the time when question was asked.

    Flutter Web not recommended

    At the current date, I would recommend not to use Flutter Web for production as it's in Beta. The Flutter Team is still working on improving quality, performance and browser compatibility. You must be cautious about using it as you may run into bugs and some other complications.

    Also, I believe that the community support for Flutter Web might be on a lower side as it's pretty new.

    Limited browser support

    Another factor which bugs me is that the Flutter web apps can run on limited browsers as of now which would affect the reach to your user base:

    What would I prefer?

    Well, although it might be a hassle to handle different codebases for mobile and web platforms, I would still prefer to stick with React JS as it's much stable with better browser & community support as opposed to Flutter Web.

    Good luck with your app! :)