[英]Concatenate list of strings into single string
I am new in flutter I want to know how can i concatenate the list of strings into a single string.我是 flutter 的新手 我想知道如何将字符串列表连接成一个字符串。 I tried to do phrase.toString().
我试着做 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.我期待输出应该是:This is a flutter learning session. 因此在这里登录。
I have tried:我努力了:
final phraseTags = phrase[index]['tags'];
but not getting the required result但没有得到所需的结果
You are having typo on tags
will be tag
您在
tags
上有错字 will be tag
final phraseTags = phrase[index]['tag'];
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.