Read Json file from assets folder - Flutter

Last updated Jul 28, 2019


Hello Guys, Today I am going to share How to read Json file from assets folder and parse teh data.

I have copied json files in Assts folder and fetch the data from that sjon files

                      

 

To read the json file from assts folder i have used below code.

DefaultAssetBundle.of(context).loadString("assets/$file")
    .then((s) {
          setState(() {
                var response = json.decode(s);
              }
           });
    }).catchError((error) {

      print(error);
    });

 

You can find the complete code at my github   rrtutors  account.

Tags: Flutter, Read local json file, Fetch Json file, Parse Json data, Gridview


Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

4835 Views

Subscribe For Daily Updates

Flutter Questions
Android Questions