Can anyone tell me how to parse arrays of arrays of object in flutter. When I am parsing the json I am getting error as
List<dynamic> is not a subtype of type Map<String, dynamic>.
I have used quicktype to write the model class and I am trying to print the worksheetData in the Future but I am getting error. Below is my json file which needs to be parsed. Please help me to fix this issue. Stuck since two days.
[
{
"_id": "5ebae61440315c41995eccc7",
"projectName": "NSM",
"sheetName": "Priliminaries - A1",
"worksheetData": [
[
{
"serial": "Sl.No",
"description": "ITEM DESCRIPTION",
"quantity": "QTY.",
"unit": "UNIT",
"unitrate": "UNIT PRICE",
}
],
null,
[
{
"serial": "1.1",
"description": "Allowance for CAR policy, Mobilization, demobilization after works, Firstaid boxes, Fire extinguishers etc.",
"quantity": 1,
"unit": "Lot",
"unitrate": 12500,
}
],
[
{
"serial": "1.2",
"description": "Demolition of existing gypsum partitions, ceilings, necessary floor tiles etc and cart away debris if any",
"quantity": 0,
"unit": "Lot",
"unitrate": 5000,
}
]
],
"__v": "0"
},
{
"_id": "5ebae61440315c41995eccc8",
"projectName": "NSM",
"sheetName": "General works -A2",
"worksheetData": [
[
{
"serial": "Sl.No",
"description": "ITEM DESCRIPTION",
"quantity": "QTY.",
"unit": "UNIT",
"unitrate": "UNIT PRICE",
}
],
null,
[
{
"serial": "1.1",
"description": "Allowance for CAR policy, Mobilization, demobilization after works, Firstaid boxes, Fire extinguishers etc.",
"quantity": 1,
"unit": "Lot",
"unitrate": 12500,
}
],
[
{
"serial": "1.2",
"description": "Demolition of existing gypsum partitions, ceilings, necessary floor tiles etc and cart away debris if any",
"quantity": 0,
"unit": "Lot",
"unitrate": 5000,
}
]
],
"__v": "0"
}
]
Main.dart
class WorkSheet extends StatefulWidget {
const WorkSheet({Key key}) : super(key: key);
@override
_WorkSheetState createState() => new _WorkSheetState();
}
class _WorkSheetState extends State<WorkSheet> {
// List<ArticleslistData> articleslist = [];
// List<ArticleslistData> list;
@override
void initState() {
setState(() {
loadSheetDataFromAssets();
});
super.initState();
}
Future loadSheetDataFromAssets() async {
var jsonData = await rootBundle.loadString('assets/Vibyor.json');
var data = json.decode(jsonData);
ArticleslistData articleslistData = new ArticleslistData.fromJson(data);
print('data : ${articleslistData.worksheetData[0]}');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Work sheet data'),
),
body: FutureBuilder(
future: loadSheetDataFromAssets(),
builder: (context, snapshot) {
return snapshot.data != null
? Text(snapshot.data)
: Center(child: CircularProgressIndicator());
}),
);
}
}

