2
votes

How do I supply flutter Card Widgets with JSON information the way I would with a tableView Controller in Swift; which is feed various arrays with titles, images, descriptions, e.g. and index off each item?

**** UPDATE with JSON decode Code

var httpClient = createHttpClient();
    var response = await httpClient.read(url);
    String data = JSON.decode(response);
    Map items = JSON.decode(data);
    Map<String, dynamic> decoded = new JsonCodec().decode(data);
    for (String key in decoded.keys) {
      print("Key $key contains: ${decoded[key]}");

I've added the above code and now I'm getting this error. Please provide any ideas on how to fix. BTW... This is coming from a YouTube ResponseList

type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String' of 'data' where
      _InternalLinkedHashMap is from dart:collection
      String is from dart:core
      String is from dart:core
1

1 Answers

1
votes
  1. Retrieve the data as a String in whatever method you choose (File I/O, Web)

  2. Decode it to a map with JSON.decode. After, I'd recommend you construct a model object with the map but this is not necessary.

  3. Supply the data to a Widget that reads said data.