Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Concatenate list of strings into single string

I am new in flutter I want to know how can i concatenate the list of strings into a single string.
I tried to do phrase.toString(). i have also tried

But I am not getting the required result. How can I get the concatenation of only tags of the list? Any help will be appreciated.

List phrase = [
      {
        'tag': 'This is a flutter',
       
      },
      {
        'tag': 'learning session',
        'icon': icon.flutter,
      },
      {
        'tag': 'Therefore,',
        'icon': icon.learningHat,
      },
      {
        'tag': 'Login here',
      },
    ];

I am expecting the out should be: This is a flutter learning session. Therefore login here.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have tried:

final phraseTags = phrase[index]['tags'];

but not getting the required result

>Solution :

use this method:

getTags(List list) {
 List listOfTagsOnly = list.map((e) => e["tag"].trim()).toList();
  return listOfTagsOnly.join(" ");
}

print(getTags(phrase)); // This is a flutter learning session Therefore, Login here
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading