title: How to rebuild widget in Flutter when a change occurs
body: <p><strong>Edit:</strong> I've edited the code below to feature the method that fetches the data along with the widgets that build the train estimates (replacing any API information along the way with <code>"API_URL"</code> and <code>"API_STOP_ID"</code>). I hope this even better helps us figure out the problem! I really appreciate any information anyone can give -- I've been working very hard on this project! Thank you all again!</p>
  
  <p><strong>Original post:</strong>
  I have a ListView of ListTiles that each have a trailing widget which builds train arrival estimates in a new Text widget. These trailing widgets are updated every five seconds (proven by print statements). As a filler for when the app is fetching data from the train's API, it displays a "no data" Text widget which is built by _buildEstimatesNull().</p>
  
  <p>However, the problem is that "no data" is still being shown even when the app has finished fetching data and <code>_isLoading = false</code> (proven by print statements). Still, even if that was solved, the train estimates would become quickly outdated, as the trailing widgets are updating every five seconds on their own but this would not be reflected in the actual app as the widgets were built on page load. Thus, I need a way to rebuild those trailing widgets whenever they fetch new information. </p>
  
  <p>Is there a way to have Flutter automatically rebuild the ListTile's trailing widget every five seconds as well (or whenever _buildEstimatesS1 is updated / the internals of the trailing widget is updated)?</p>
  
  <pre><code>class ShuttleApp extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() {
      return new ShuttleState();
    }
  }
  
  class ShuttleState extends State&lt;ShuttleApp&gt; {
    @override
    Widget build(BuildContext context) {
      return new MaterialApp(
        home: new HomeScreen(),
      );
    }
  }
  
  class HomeScreen extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() {
      return new HomeState();
    }
  }
  
  class HomeState extends State&lt;HomeScreen&gt; {
  
    var _isLoading = true;
  
    void initState() {
      super.initState();
      _fetchData();
      const fiveSec = const Duration(seconds: 5);
      new Timer.periodic(fiveSec, (Timer t) {
        _fetchData();
      });
    }
  
    var arrivalsList = new List&lt;ArrivalEstimates&gt;();
  
    _fetchData() async {
      arrivalsList.clear();
      stopsList.clear();
      final url = "API_URL";
      print("Fetching: " + url);
      final response = await http.get(url);
      final busesJson = json.decode(response.body);
      if (busesJson["service_id"] == null) {
        globals.serviceActive = false;
      } else {
        busesJson["ResultSet"]["Result"].forEach((busJson) {
          if (busJson["arrival_estimates"] != null) {
            busJson["arrival_estimates"].forEach((arrivalJson) {
              globals.serviceActive = true;
              final arrivalEstimate = new ArrivalEstimates(
                  arrivalJson["route_id"], arrivalJson["arrival_at"], arrivalJson["stop_id"]
              );
              arrivalsList.add(arrivalEstimate);
            });
          }
        });
      }
      setState(() {
        _isLoading = false;
      });
    }
  
    Widget _buildEstimateNull() {
      return new Container(
        child: new Center(
          child: new Text("..."),
        ),
      );
    }
  
    Widget _buildEstimateS1() {
      if (globals.serviceActive == false) {
        print('serviceNotActive');
        _buildEstimateNull();
      } else {
        final String translocStopId = "API_STOP_ID";
        final estimateMatches = new List&lt;String&gt;();
        arrivalsList.forEach((arrival) {
          if (arrival.stopId == translocStopId) {
            estimateMatches.add(arrival.arrivalAt);
          }
        });
        estimateMatches.sort();
        if (estimateMatches.length == 0) {
          print("zero");
          return _buildEstimateNull();
        } else {
          return new Container(
            child: new Center(
              child: new Text(estimateMatches[0]),
            ),
          );
        }
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
          backgroundColor: const Color(0xFF171717),
          appBar: new AppBar(),
          body: new DefaultTextStyle(
            style: new TextStyle(color: const Color(0xFFaaaaaa),),
            child: new ListView(
              children: &lt;Widget&gt;[
                new ListTile(
                  title: new Text('S1: Forest Hills',
                      style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 20.0)),
                  subtitle: new Text('Orange Line'),
                  contentPadding: new EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
                  trailing: _isLoading ? _buildEstimateNull() : _buildEstimateS1(),
                ),
              ],
            ),
          )
      );
    }
  
  class ArrivalEstimates {
    final String routeId;
    final String arrivalAt;
    final String stopId;
    ArrivalEstimates(this.routeId, this.arrivalAt, this.stopId);
  }
  </code></pre>
  
  <p>Thank you so much in advance for any help you can give! I really super appreciate it! :)</p>