Search code examples
flutterdart

How to fetch the data from the API and store into a variable in flutter?


I need to fetch some data from the API and the data I need to store the data in a variable.


Solution

  • You should consider to create an object where you want to put your json data. more likely you use http package for retrieving data from api then store it in your created object. usually api data formatted as json format, in that case you use dart:convert for Serializing JSON. For displaying the output you're about to use the getter to retrieve the data from your object.