i have this
String stringArray = "[folder/1.png,folder/2.png,folder/3.png]";
this is what i want
List array = ["folder/1.png","folder/2.png","folder/3.png"]
converting to this
List array = ["folder/1.png","folder/2.png","folder/3.png"]
i have this
String stringArray = "[folder/1.png,folder/2.png,folder/3.png]";
this is what i want
List array = ["folder/1.png","folder/2.png","folder/3.png"]
converting to this
List array = ["folder/1.png","folder/2.png","folder/3.png"]
3
Answers
stringArray.split(",");
stringArray.map((file) => file.replaceAll("[", "").replaceAll("]",""));
Lets say you have this:
You can parse it with
jsonDecode
method, like this:your result would be:
Try the following simple code snippet:
It’s now converted to
List<String>
and here’s the output:Note: IDEs ignore the quotation marks, usually not displayed.
If you really want to surround that string with quotes replace the above
for
loop to that :Here’s the output:
Hope it helps you.