将列表中的字符串项与另一个字符串合并

时间:2019-09-05 10:15:28

标签: flutter dart

是否可以将列表中的String项目与另一个字符串合并? 例如:
我有这个清单

final list1 = ['Hello'];

我需要在单击按钮时将World字添加到Hello字中 所以列表将是 ['Hello World']

1 个答案:

答案 0 :(得分:1)

使用

final list1 = ['Hello']; // given

String hello = list1[0]; // get first letter
String world = 'World'; // letter you want to add

list1[0] = hello + ' ' + world; // concatenate both string and update list