I am asking for help because I don't know how to solve this issue. I am currently mapping on an Array of object with this code to output an array of string :
contexts = snapshot.data!.myContexts
.where(
(e) => e.organisation.name == organizationValue)
.map((e) => e.projects.map((e) => e.name)).toList();
The last .toList make the difference in the output value from getting an array of list [()] and a list of list (()).
I wanted to know How I could get only a list of string or an array of string. Thank you in advance, Weac
CodePudding user response:
Can you try creating the list this way ?
final organization = snapshot.data!.myContexts
.firstWhere(
(e) => e.organisation.name == organizationValue);
contexts = List<String>.generate(organization.projects.length,(index)=>organization.projects[index].name);
Assuming the organization is always unique and you can't have two organization with the same name.