title: Convert json to list in flutter
body: <p>I have a dynamic data from json, then I want to change it to a list variable, so i can be called that variable by the getSuggestions function.
  Here is the code :</p>
  
  <pre><code>static List&lt;String&gt; people = new List&lt;String&gt;();
  
    void getUsers() async {
      try {
        final response =
            await http.get("https://jsonplaceholder.typicode.com/users");
        var resbody = json.decode(response.body);
        var data = json.encode(resbody[0]);
        if (response.statusCode == 200) {
          setState(() {
            people = data;
          });
        } else {
          print("Error getting users.");
        }
      } catch (e) {
        print("Error getting users.");
      }
    }
  
    static List&lt;String&gt; getSuggestions(String query) {
      List&lt;String&gt; matches = List();
      matches.addAll(people);
  
      matches.retainWhere((s) =&gt; s.toLowerCase().contains(query.toLowerCase()));
      return matches;
    }```
  </code></pre>