title: Flutter http get request json serialization
body: <p>I would like to make a get requests and to convert results to a list of objects.
  Actually i did that :</p>
  <p>post_model.dart</p>
  <pre><code>@JsonSerializable()
  class Post {
  
    Post({
      required this.userId,
      required this.id,
      required this.title,
      required this.body,
    });
  
    factory Post.fromJson(Map&lt;String, dynamic&gt; json) =&gt; _$PostFromJson(json);
    Map&lt;String, dynamic&gt; toJson() =&gt; _$PostToJson(this);
  
    final int userId;
    final int id;
    final String title;
    final String body;
   
  }
  </code></pre>
  <p>http_service.dart :</p>
  <pre><code>class HttpService {
    final String url = 'https://jsonplaceholder.typicode.com';
    final String postsURL = '/posts';
    final Map&lt;String, String&gt; headers = {
      'Content-Type': 'application/json'
    };
  
  
    List&lt;Post&gt; parsePosts(String responseBody) {
      final parsed = jsonDecode(responseBody).cast&lt;Map&lt;String, dynamic&gt;&gt;();
      return parsed.map&lt;Post&gt;((json) =&gt; Post.fromJson(json)).toList();
    }
  
  
    Future&lt;List&lt;Post&gt;&gt; fetchPosts() async {
  
      final http.Response response = await http.get(Uri.https(url, postsURL));
  
      if (response.statusCode == 200) {
        return compute(parsePosts,response.body);
      } else {
        throw Exception(&quot;Failed to load posts ${response.statusCode}&quot;);
      }
    }
  
  
  }
  </code></pre>
  <p>But i encouter all in red on the parsePosts method.
  On the final parsed :</p>
  <pre><code>Missing variable type for 'parsed'.
  Try adding an explicit type, or remove implicit-dynamic from your analysis options file.dart(implicit_dynamic_variable)
  </code></pre>
  <p>and on the return :</p>
  <pre><code>A value of type 'dynamic' can't be returned from the method 'parsePosts' because it has a return type of 'List&lt;Post&gt;'
  </code></pre>
  <p>I just don't understand what i'm doing wrong, because i have follow the flutter doc here :
  <a href="https://flutter.dev/docs/cookbook/networking/background-parsing" rel="nofollow noreferrer">https://flutter.dev/docs/cookbook/networking/background-parsing</a></p>
  <p>Thanks for any help</p>