![](/img/trans.png)
[英]List of Strings converts to single String in POST REST api Dart/Flutter
[英]Concatenate list of strings into single string
我是 flutter 的新手 我想知道如何將字符串列表連接成一個字符串。 我試着做 phrase.toString()。 我也試過
但我沒有得到所需的結果。 我怎樣才能得到列表中唯一標簽的串聯? 任何幫助將不勝感激。
List phrase = [
{
'tag': 'This is a flutter',
},
{
'tag': 'learning session',
'icon': icon.flutter,
},
{
'tag': 'Therefore,',
'icon': icon.learningHat,
},
{
'tag': 'Login here',
},
];
我期待輸出應該是:This is a flutter learning session. 因此在這里登錄。
我努力了:
final phraseTags = phrase[index]['tags'];
但沒有得到所需的結果
您在tags
上有錯字 will be tag
final phraseTags = phrase[index]['tag'];
使用此方法:
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.