Stack Exchange
_CastError (type '_Map<String, dynamic>' is not a subtype of type 'String' in type cast) [wlifecycle]
class _HomeState extends State<Home> {

List currency = [];
Future getResponse(BuildContext context) async {
var url =
"http://api.navasan.tech/latest/?api_key=freeTFyHoFiXvgG6UNOlQHfehDasa7eK";
var value = await http.get(Uri.parse(url));
developer.log(value.body, name: 'main');
developer.log('getResponse', name: 'wlifecycle');
if (currency.isEmpty) {
  if (value.statusCode == 200) {
    _showSnackBar(context, 'به روز رسانی با موفقیت انجام شد .');
    developer.log(value.body,
        name: 'getResponse', error: convert.jsonDecode(value.body));
    Map jsonList = convert.jsonDecode(value.body);
    if (jsonList.isNotEmpty) {
      jsonList.forEach((key, value) {
        setState(() {
          currency.add(Currency(
              id: jsonList[key],
              value: jsonList[key]["value"],
              change: jsonList[key]["change"],
              timestamp: jsonList[key]['timestamp'],
              date: jsonList[key]["date"]));
        });
      });
    }
  }
}
return value;

}

API :
{
"harat_naghdi_buy": {
"value": "49970",
"change": -720,
"timestamp": 1678374494,
"date": "1401-12-18 18:38:14"
},
}
Model :
// ignore: file_names
class Currency {
String? id;
int? value;
int? change;
int? timestamp;
String? date;
Currency(
{required this.id,
required this.value,
required this.change,
required this.timestamp,
required this.date});
}

Consider changing the code in the setState to :
if (jsonList.isNotEmpty) {
  jsonList.forEach((key, value) {
    var currencyObj = Currency(
        id: key,
        value: value['value'],
        change: value['change'],
        timestamp: value['timestamp'],
        date: value['date']);
    setState(() {
      currency.add(currencyObj);
    });
  });
}


Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
line 71 > value: value['value],
