How to convert String List to String in flutter?
print(list.toString().replaceAll('[', '').replaceAll(']',''))
if you know you have List<String>
then you can use join()
function provided by a flutter.
var list = ['one', 'two', 'three'];
var stringList = list.join("");
print(stringList); //Prints "onetwothree"
Simple and short. ;)
And you can use it like this:
List<String> servicesList = ["one", "Two", "Thee"];
print(servicesList.join(""));
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'
}
You can use reduce method on a list like that:
List<String> list = ['one', 'two', 'three'];
final string = list.reduce((value, element) => value + ',' + element);
// For your example:
List<String> servicesList = await SharedPrefSignUp.getSelectedServices();
selectServicesText = servicesList.reduce((value, element) => value + ',' + element);