Getting json string from api but how to use it in flutter app?

Viewed 21
var res = await http.get(Uri.parse("SomeEndPoint"));
var data1 = jsonDecode(res.body);

this is my code what next i do to use it in flutter app

1 Answers

Well, you can get all the information in the data, for example:

final data = jsonDecode(res.body);

// For example this data looks like this:

// {
//    "id": "hZs68Hs7u",
//    "message": "Hello",
// }

Now you can access the fields in it and do whatever you want:

final String id = data["id"];
final String message = data["message"];
Related