如何在颤振中将字符串列表转换为字符串? [英] How to convert String List to String in flutter?

查看:76
本文介绍了如何在颤振中将字符串列表转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在飞镖中将List转换为字符串.

I need to convert List into a string in the dart.

我想从首选项中提取列表的值.我已经尝试过该实现,但是它只是给了我最后的价值.

I want to extract the value of the list from preferences. I have tried this implementation but it is only giving me the last value.

   Future<List<String>> 
    services=SharedPrefSignUp.getSelectedServices();
     services.then((onValue){
  List<String>servicesList=onValue;
  selectServicesText=servicesList.join(",");
});

推荐答案

您可以使用StringBuffer迭代列表和连接值

You can iterate list and concatenate values with StringBuffer

  var list = ['one', 'two', 'three'];
  var concatenate = StringBuffer();

  list.forEach((item){
    concatenate.write(item);
  });

  print(concatenate); // displays 'onetwothree'

  }

这篇关于如何在颤振中将字符串列表转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆