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

Flutter: How to convert list to string?

I have a list. I want to convert it to string. However, the results are a bit different from what I expected.

Expected result:

'["a", "b", "c", "d"]'

Actual result:

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

[a, b, c, d]

My code:

final List list = ["a", "b", "c", "d"];

print(list.toString());

How can I get my expected results? I would appreciate any help. Thank you in advance!

>Solution :

You could use the jsonEncode of it to get the desired result:

print(jsonEncode(list));
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