Issue
I need to convert List<String>
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(",");
});
Solution
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'
}
Answered By - Rubens Melo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.