Closed Nedimko123 closed 1 year ago
@Nedimko123 – it is confusing.
What code do you want to write and what code do you want generated?
How can I get the field name like I can with regular List<Map<String, dynamic>>
const List<Map<String, dynamic>> jsonFoods = [
{
"category": "Human milk",
"id": 11000000,
"description": "Milk, human",
"energy": 70,
"protein": 1.03,
"carbohydrate": 6.89,}];
for (var element in jsonFoods) {
element.forEach((key, value) {
print('$key - $value');
});
}
which then returns
category - Human milk
id - 11000000
description - Milk, human
energy - 70
protein - 1.03
carbohydrate - 6.89
We have to talk in terms of what code you want to write and what code you want generated.
Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll reopen the case if you do. Thanks for your contribution!
This might be confusing...
Lets say we have a model
Is it possible that I can describe a specific field, for example street = "a public road in a city, town, or..." The scenario is like this: Text(Street.name, street.description) //describes what a street is -- Text( address[index].street), //value for a specific address input Text(City.name, city.description ) //describe what a city is -- Text(address[index].city,) //value for a specific address input
the JSON is Map<String, dynamic> = {'street' : 123 , 'city' : 123};
So I would make a helper class thats says street = {'name' : blabla, 'description' : blabla} etc...
In my case I have over 100 json fields, so I think that creating 100+ models for each field might be time consuming