Flutter: Send data from backend to frontend without request

112

To get the desired behaviour you're looking for, you'll need an open connection between your flutter app and the micronaut server.

This can be done with:

  1. Server side push events (SSE).
  2. Websockets

I haven't tried the SSE but websocket connections work well in my experience. A popular websocket client is socket.io although I'm not sure if micronaut supports socket.io.

Share:
112
ajinzrathod
Author by

ajinzrathod

Updated on January 04, 2023

Comments

  • ajinzrathod
    ajinzrathod over 1 year

    I am using 3 tools to build my App.

    1. Third party tool
    2. Micronaut / Spring boot
    3. Flutter

    Whenever a third party tool sends some data to my Micronaut application, micronaut processes the data and makes some changes as per requirements. Now micronaut will send some data to my frontend application(flutter)

    I am very new to Flutter and I know I can get data when I make an API call but my question is that how can micronaut send data to my Flutter App without an API request. I want to send data to my flutter app as soon as micronaut completes processing the data.


    This is not specific to micronaut, you can even give me solution for how to do this in spring boot. I just want to know how can I achieve this.

    Thanks in advance

    • Rukka
      Rukka about 2 years
      Try looking into socket.io and StreamBuilder.
    • Jeff Scott Brown
      Jeff Scott Brown about 2 years
      @Rukka Can you share any more details of how to use StreamBuilder to send data to the Flutter app without making an API request? Are you talking about using that in the context of a web socket, or something else?
    • Rukka
      Rukka about 2 years
      Yes, use websockets to listen for requests and StreamBuilder to rebuild your UI accordingly
  • James Kleeh
    James Kleeh almost 2 years
    Micronaut has its own support for websocket clients and servers