Home > Software engineering >  FLUTTER API: can't use ".body"
FLUTTER API: can't use ".body"

Time:07-11

I can't use ".body" , even if im trying to just "print(result.body);"

Im getting this error message: Error i get

String url = "https://jsonplaceholder.typicode.com/posts/1/comments";

    var result = http.get(Uri.parse(url));
    apiList = jsonDecode(result.body)

I have no idea how to fix, any help is welcomed. If you need aditional information, im ready to provide

CodePudding user response:

make your function async, then

var result = await http.get(Uri.parse(url));
  • Related