I am fetching data from a SQLite database. What I need to do is put data in one array. Right now, I'm doing this in my foreach loop. I'm able to to put data in one array, but issue is I need to customize the array.
This is my code
var allRows = await dbHelper.queryAllRows();
allRows.forEach((row) {
items.add(row);
amount += double.parse(row['price']);
print(amount);
print(row);
print(items);
});
You can see I am simply putting row in Items array, but I need to customize it like this
"OrderDetails": [
{
"ItemID": row['id'],
"ItemName": row['title'],
"Quantity": 1,
"Price": 12,
"OrderDetailModifiers": [
{
"ModifierName": row['sizeselect']",
},
{
"ModifierName": row['color']",
}
]
}
]
This is the structure. Basically, it's a body of postman API I need to post data like this. So I need to customize the Items array, right now I'm simply putting all rows in Items array.
question from:https://stackoverflow.com/questions/65938709/how-to-customize-array-values