Can I use Vaadin 14 as an endpoint for a Flutter app?

I have a Vaadin 14 app that (obviously) delivers a web app in front of a java backend. All good.

I am also building a tiny Flutter app that I want to integrate with the java backend via some simple-as-possible client-server interface using json to transport both the request and the response payloads.

I am looking for a minimal way to provide an “endpoint” for the Flutter app to call. Of course I could spool up another http-server and accept calls on some port, but first I want to explore if we can simply put the json through Vaadin. For the endpoint the client will be a Flutter app, not a browser.

I have successfully trialled using the simplest possible Vaadin class (

  • just a Span
  • implements HasUrlParameter so that it can receive the data
  • with a Route (“testappendpoint”) for Flutter to call.

When I receive the URL parameter I can process it and then write the response json into the page for the Flutter app to retrieve its response.

It seems to work fine :slightly_smiling_face:

Flutter-to-java seems to be happy to put the json in the URL.
Java-to-Flutter seems ok, although there is a unnecessary overhead (styling, javascript etc) in the returned data, but the Flutter app could extract the json response.

FYI performance requirements are VERY modest with a max of maybe 5 Flutter instances connecting over the course of a day.

Questions

  1. Is this endpoint approach feasible? Or am I missing something horrible?
  2. Can the returned page be trimmed down? (ie remove styling etc)

Any guidance is appreciated. If this is feasible this will save a large amount of work.

Thx.

Don’t do that. Use a proper endpoint like RestEndpoint if you are using spring boot for example as underlying container.

That’s what I would expect - I just don’t understand why. Of course it feels wrong to even contemplate … but if it works why not? What are the actual risks? This is my-code-talking-to-my-code so I’m just passing some json around. Get a String and return a String. A few calls per hour. FYI we don’t use Spring, so would have to spin up another solution and find a separate path/port/error handing etc.

Trust me, future you is going to hate you. I would like to remind you of the law of instruments, not everything is a nail if you’ve got a hammer.

If you don’t use spring you are still in a servlet container and can get a separate servlet up and running.

Thx. I do trust you. I agree with you. But I don’t have the level of understanding to know why. Yes … after several decades in SW & mgmt I do recognise many such issues. You can also say “don’t reinvent the wheel” or “premature optimisation is the root of all evil”. I just don’t know which side of the coin this lands. I’ve used Vaadin to transform a significant desktop product into a web product using the same java backend, where Vaadin has shielded me (or hindered me?) from needing a deeper understanding of many web related concepts such as servlets. I still don’t know where all that starts and finishes. So far I have not needed to know., and that seems to be an absolute core selling point of Vaadin. Plenty of other issues to apply my limited capacity to.

Personally going one step back, I would ask myself - do I really need a flutter app with a low body count or would it be possible to build the views needed by those people with Vaadin in a responsive manner?

For sure. Excelent suggestion that I worked on for about 6 weeks. I wish I knew more about that too :slightly_smiling_face: That was my first attempt and it works really well in Android, and it is very poor on iPhones. It is the scrolling and dragging that works poorly, and occasionally it tries to zoom in. I’ve tried on different Chrome, Firefox, Safari etc. If that could be solved I have a working “device” solution. The other thing is that we need to take some images on those phones, and sometimes they are largish, which slows it all down. Not a showstopper. Flutter has more on board tools to do things like shrink. I would pay good money if anyone new how to make it work on iPhones. It is my preferred solution by far.

My application is working good on mobile and desktop… so I would say it works fine :sweat_smile: if you have good money to spare, you can probably reach out to Vaadin directly about help, especially if you have problems that only manifests on specific devices or need a refresher / helping / coding hand about to get started with “mobile development” with Vaadin.

@practical-rat do you happen to know if you guys have a matching assessment?

I second knoobie’s suggestion: using REST endpoints is the proper way to do things, and more fundamentally, it might be worth considering building Vaadin views in a responsive manner instead of using Flutter.

@open-minded-bear, if you are interested, our consultants can help create a POC of mobile-ready Vaadin views. Just DM me your contact details if you are interested.