title: How to get list from JSON data to display in widget?
body: <p>I have been making a simple app which displays crypto coins and their price, data, market cap etc. I am using CoinGeckGo API.</p>
  <pre><code>    import 'dart:async';
  import 'dart:convert';
  import 'package:http/http.dart' as http;
  import 'package:flutter/material.dart';
  
  class Coin {
    String? coinName;
    String? coinPrice;
    String? coinImgUrl;
    String? coinVol;
    Coin(
        {@required this.coinName,
        @required this.coinPrice,
        @required coinImgUrl,
        @required coinVol});
  }
  
  class Coins {
    Future&lt;List&lt;Coin&gt;&gt; fetchCoinsData() async {
      var uri = Uri.parse(
          &quot;https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&amp;order=market_cap_desc&amp;per_page=100&amp;page=1&amp;sparkline=false&quot;);
      final response = await http.get(uri);
      final json = await jsonDecode(response.body);
      List&lt;Coin&gt; coins = [];
      for (int i = 0; i &lt; json.length; i++) {
        Coin coin = Coin(
          coinImgUrl: json[i][&quot;image&quot;].toString(),
          coinName: json[i][&quot;symbol&quot;].toString(),
          coinPrice: json[i][&quot;current_price&quot;].toString(),
          coinVol: json[i][&quot;total_volume&quot;].toString(),
        );
       coins.add(coin);
      }
  
      return coins;
    }
  }
  </code></pre>
  <p>this is my function to fetch data from json api and add them into list so that i get values from that list to display in widget.</p>
  <p>but when I am calling this function in init state, and assign fetched return value to a list i get output &quot;Instance of 'Coin', but it should be like <code>{coinName:'btc',coinPrice: '48000', coinVol: 478965455</code>
  like that
  below is code i am calling function inside initstate.</p>
  <pre><code>class _MyHomePageState extends State&lt;MyHomePage&gt; {
    List&lt;Coin&gt; my_list = [];
    bool? _isLoading;
  
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      _isLoading = true;
      Coins().fetchCoinsData().then((List&lt;Coin&gt; value) {
        print(value);
        my_list = value;
        _isLoading = false;
      });
    }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/YsKZ0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YsKZ0.png" alt="This is what output I am getting instead of coin data" /></a></p>