-1

To use api in flutter apps I usually use https url with different keys. But I want to know how can I use an api like the following

enter image description here

It has request url but also something called request body. How can I use it in flutter. And how can request body be used with url. Is there any flutter package that can help me?.

Can you give an example code of how url will look??

Bhavya Budhia
  • 115
  • 1
  • 2
  • 10

1 Answers1

0

use http package https://pub.dev/packages/http to get request or post request to an api. It will send response back and then can use jsonDecode to decode json string. Check out this article for step by step explanation https://flutter.dev/docs/cookbook/networking/background-parsing

Sachin Bhankhar
  • 900
  • 8
  • 14
  • Can you give an example code of how url will look? The article talks about simple url passing that I know. I just can't understand what these request body fields are. – Bhavya Budhia Jun 10 '20 at 18:02
  • You can get and post data using body of that request which is generally a json object if you want to send data using url then use `queryParameters` option in dio and http package. https://stackoverflow.com/questions/52824388/how-do-you-add-query-parameters-to-a-dart-http-request – Sachin Bhankhar Jun 10 '20 at 18:21