Read Json file from assets folder - Flutter

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