I am new to flutter dart and having trouble, with the syntax, to pass a list with multiple blocks to a function.
This is my list:
Final list = [
{
'name' : 'abc',
'age : '25',
'gender' : 'M',
},
{
'name' : 'def',
'age : '26',
'gender' : 'F',
},
{
'name' : 'ghi',
'age : '25',
'gender' : 'M',
},
];
Lets say this is my function that will show the output:
Myfunc ()
{
Text('name'),
Text('age'),
Text('gender')
};
So how will i write this function in actual syntax, (ignore some basic widgets).
Thanks in advance for reading this and helping ^^
2
Answers
You can do the following to pass an item to your function:
Are you trying to loop through your list and create a widget like this example?
Your list contains maps (also know as dictionary in other languages). If this is written in Dart it will look like this.
In a full Flutter application this is how it will look like.
You can swap a
Column
with aRow
, the only difference is that items in a row will be arranged horizontally.I also suggest that you read more on Dart collection operators here.