title: How to add an item to a custom list in flutter?
body: <p>I am facing a small problem, I cannot add an item to my custom list.</p>
  <pre><code>Future&lt;KitchenProducts&gt; createAlbum(String barcode) async {
  final http.Response response = await http.post(
  'https://mysite',
  headers: &lt;String, String&gt;{
    'Content-Type': 'application/json; charset=UTF-8',
  },
  body: jsonEncode(&lt;String, String&gt;{
    'barcode': barcode,
  }),
  );
  
  // Use the compute function to run parsePhotos in a separate isolate.
  print(response.body);
  return compute(parseResponse, response.body);
  }
  
  KitchenProducts parseResponse(String responseBody) {
  final parsed = jsonDecode(responseBody).cast&lt;Map&lt;String, dynamic&gt;&gt;();
  
  return parsed.map&lt;KitchenProducts&gt;((json) =&gt; 
  KitchenProducts.fromJson(json));
  }
  </code></pre>
  <p>I am sending an http request and I get some information that I want to add to the list.
  My list:</p>
  <pre><code>List&lt;KitchenProducts&gt; products = [];
  </code></pre>
  <p>Function for adding an item to a list:</p>
  <pre><code>await createAlbum(barcodeScanRes).then((value) {
    products.add(KitchenProducts(code: value.code, name: value.name, weight: value.weight));
  }).catchError((error) {
    print(error.toString());
  });
  </code></pre>
  <p>As a result, I get the error:</p>
  <blockquote>
  <p>Exception: type 'List&lt;KitchenProducts'&gt; is not a subtype of type 'KitchenProducts'</p>
  </blockquote>
  <p>And my model:</p>
  <pre><code>class KitchenProducts {
  
  String code;
  String name;
  double weight;
  
  KitchenProducts({this.code, this.name, this.weight});
  
  factory KitchenProducts.fromJson(Map&lt;String, dynamic&gt; json) {
  return KitchenProducts(
    code: json['code'],
    name: json['name'],
    weight: json['weight'],
    );
   }
  }
  </code></pre>
  <p>Tell me what am I doing wrong?</p>