title: Flutter refresh JSON every minute automatically
body: <p>I have searched the web for auto refresh widgets and auto refresh future JSON for Flutter but the results all seem to be for pull down refresh.</p>
  
  <p>What I need is like a function that I can call and every minute that said function repeats.</p>
  
  <p>I know I have to integrate something like: </p>
  
  <pre><code>var future = new Future.delayed(const Duration(milliseconds: 10), TracksWidget());
  </code></pre>
  
  <p>However I am not sure where I need to put it.</p>
  
  <pre><code>import 'dart:async';
  import 'dart:convert';
  
  import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  import '../model/track.dart';
  
  class TracksWidget extends StatefulWidget {
    @override
    _TracksWidgetState createState() =&gt; _TracksWidgetState();
  }
  
  class _TracksWidgetState extends State&lt;TracksWidget&gt; {
    Future&lt;Track&gt; track;
  
    @override
    Widget build(BuildContext context) {
      double c_width = MediaQuery.of(context).size.width;
      return new FutureBuilder&lt;Track&gt;(
        future: track,
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            Track track = snapshot.data;
            return new Container(
                padding: const EdgeInsets.all(16.0),
                width: c_width,
                child: new Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: &lt;Widget&gt;[
                          Image.network(track.imageurl, width:200.0, height: 200.0,fit: BoxFit.cover),
                          Text(track.title),
                          Text(track.artist),
                ]),
            );
          } else if (snapshot.hasError) {
            return Text("${snapshot.error}");
          }
          //By default, show a loading spinner.
          return CircularProgressIndicator();
        },
      );
    }
  
    @override
    void initState() {
      super.initState();
      track = fetchTrack();
    }
  
  
    Future&lt;Track&gt; fetchTrack() async {
      final response =
          await http.get('http://139.59.108.222:2199/rpc/drn1/streaminfo.get');
  
      if (response.statusCode == 200) {
        // If the call to the server was successful, parse the JSON.
        var responseJson = json.decode(response.body);
        // assume there is only one track to display
        // SO question mentioned 'display current track'
        var track = responseJson['data']
            .map((musicFileJson) =&gt; Track.fromJson(musicFileJson['track']))
            .first;
        return track;
      } else {
        // If that call was not successful, throw an error.
        throw Exception('Failed to load post');
      }
    }
  }
  </code></pre>