title: Refresh list after deleting an item - Flutter
body: <p>I am trying to get the list to automatically refresh after the delete option on pop up menu is pressed. It will delete the selected 
    item from a list of items called from an api. That item should immediately dissapear after delete is pressed on it.</p>
  
  <p>API call that fills the list with api data:</p>
  
  <pre><code>  List data;
  
    @override
    void initState() {
      super.initState();
      this.getJsonData();
    }
  
    Future&lt;String&gt; getJsonData() async {
      var response = await http.get(
        Uri.encodeFull(url),
        headers: {"Accept": "application/json"},
      );
  
      var extractdata = json.decode(response.body);
      data = extractdata['levels'];
      levelsData = data;
  
      setState(
        () {
          var extractdata = json.decode(response.body);
          data = extractdata['levels'];
        },
      );
      return "Success";
    }
  </code></pre>
  
  <p>...</p>
  
  <p>Api call that deletes: </p>
  
  <pre><code>  delete() async {
      String url = "http://31.183.125.253:8080/users";
  
      Map map = {
        'price': 1.23,
        'user_id': 'user2'
      };
  
      print(await apiRequest(url, map));
    }
  
    Future&lt;String&gt; apiRequest(String url, Map jsonMap) async {
      HttpClient httpClient = new HttpClient();
      HttpClientRequest request = await httpClient.deleteUrl(Uri.parse(url));
      request.headers.set('content-type', 'application/json');
      request.add(utf8.encode(json.encode(jsonMap)));
      HttpClientResponse response = await request.close();
      String statusCode = response.statusCode.toString();
      String reply = await response.transform(utf8.decoder).join();
  
      print(statusCode);
  
      httpClient.close();
      return reply;
    }
  </code></pre>
  
  <p>Expansion tile that stores the list from api call:</p>
  
  <p>...</p>
  
  <pre><code>var levelsData = [];
  
    @override
    Widget build(BuildContext context) {
      List&lt;dynamic&gt; _getChildren() {
        List&lt;Widget&gt; children = [];
        levelsData.forEach(
          (element) {
              children.add(
                ListTile(
                  title: Text(element['price'].toString(),
                  trailing: PopUpMenu(
                    onDelete: () {
                      setState(() {
                        delete();
                      });
                    }))
              );}
        );
        return children;
      }
    }
  </code></pre>
  
  <p>...</p>
  
  <p>Pop up menu:</p>
  
  <pre><code>class PopUpMenu extends StatelessWidget {
    VoidCallback onDelete;
  
    PopUpMenu({this.onDelete});
  
    void showMenuSelection(String value) {
      switch (value) {
        case 'Delete':
          onDelete();
          break;
        // Other cases for other menu options
      }
    }
  </code></pre>
  
  <p>I am able to delete the item selected to delete but the item doesnt dissapear from the list and it didnt show the changes of the list.</p>