I am getting this error after using JSON data into text wigdet. My json is stored locally in
assets/json/data.json
I am building a Listview using ListView.builder
My code
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xff655ee6),
appBar: AppBar(
backgroundColor: Color(0xff655ee6),
title: Text("Apply Online"),
),
body: SingleChildScrollView(
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: FutureBuilder(
future: DefaultAssetBundle.of(context).loadString("assets/json/example.json"),
builder: (context,snapshot){
var mydata = json.decode(snapshot.data.toString());
if(mydata == null){
return Center(
child: CircularProgressIndicator(
),
);
}
else {return ListView.builder(
itemCount: 30,
itemBuilder: (context, index){
return Card(
child: ListTile(
title: Text(mydata["saarthiService"]['applyOnline']["0"]),
leading: Icon(Icons.import_contacts),
),
);
},
);}
},
),
),
),
);
}
}
Please Help Me and I am new to flutter Thanks