title: flutter - realtime stream data from REST API
body: <p>I am retrieving data from a REST API using a stream, but when the data updates in the database the stream does not refresh the data in the app.</p>
  
  <pre><code>StreamController _productsController = new StreamController();
  ...         
  //products is a list that contains the data
  _productsController.add(products);
  ...
  body: Container(
          child: StreamBuilder(
              stream: _productsController.stream,
              builder: (BuildContext context, AsyncSnapshot snapshot) {...}
  </code></pre>
  
  <p>I saw a solution proposing to periodically re-load the data from the API, for example each 1 second.</p>
  
  <pre><code>Timer.periodic(Duration(seconds: 1), (_) =&gt; loadDetails());
  </code></pre>
  
  <p>Source: <a href="https://stackoverflow.com/questions/57554659/stream-for-api-coming-from-php-in-flutter-not-firebase">Stream for API coming from PHP in Flutter (Not Firebase)</a></p>
  
  <p>I do not think it is an efficient approach. In my app for example, I want to integrate the data changes without re-loading the data.</p>
  
  <p>Is there an efficient way to make the stream reflects data changes in the app without reloading data?</p>