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(",");
});
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(""));