I am new in flutter I want to know how can i concatenate the list of strings into a single string. I tried to do phrase.toString(). i have also tried
But I am not getting the required result. How can I get the concatenation of only tags of the list? Any help will be appreciated.
List phrase = [
{
'tag': 'This is a flutter',
},
{
'tag': 'learning session',
'icon': icon.flutter,
},
{
'tag': 'Therefore,',
'icon': icon.learningHat,
},
{
'tag': 'Login here',
},
];
I am expecting the out should be: This is a flutter learning session. Therefore login here.
I have tried:
final phraseTags = phrase[index]['tags'];
but not getting the required result
CodePudding user response:
use this method:
getTags(List list) {
List listOfTagsOnly = list.map((e) => e["tag"].trim()).toList();
return listOfTagsOnly.join(" ");
}
print(getTags(phrase)); // This is a flutter learning session Therefore, Login here
CodePudding user response:
You are having typo on tags
will be tag
final phraseTags = phrase[index]['tag'];