How to change to type of response to Map in flutter


I try to make a GET http call from flutter to Nodejs. The data I get is in json form but when I try to manipulate it with flutter I can’t because the response is of type RESPONSE or I can change it to string I don’t know how to change the response to type Map to help me manipulate the data I get.

here the code :

Future getYear() async {
    var url = "";
    var response = await http.get(Uri.parse(url));
    var jsonresponse = await json.decode(json.encode(response.body));

and here the data I get but I can’t manipulate it [{"year":2019},{"year":2020}]


jsonDecode(response.body) decodes the response to Map<String,dynamic>.

Answered By – esentis

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *