In this article we are going to fetch data using REST API in the most easiest way possible and display them in our flutter app using a List view .
We will create a simple flutter app and remove all the default code included in the main.dart file. Then we are going to simply call a HomeScreen() function which includes all the core funtions required for the API call.
download code : click here
We are going to use randomuser api for this project.
Read the full documentation of the API : read more
We will make a statefull widget and declare a List to store the fetched data and view it. then we will return a scaffold and in the body we will define the ListView. The ListView will have certain fields to be displayed.We will parse the URL and store the response in body and then use jsonDecoder wil decode the response and map them successfully. We will also have a floating action button will on click will trigger a function and fetch all the records with limits.
So finally we have fetched records using REST API in Flutter.
Final Thoughts
I hope you find this article helpful and worth it. Feel free to share it with your developer friend.
Happy Coding 🙌
0 Comments