THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.
This tutorial shows multiple ways to convert a String into an array or list in dart and flutter programming.
String.split()
methodtrim
method, and split using split()
methodSince Array does not support Dart. We will show you to convert to List only.
String.split()
method split the string with the delimiter.
The default delimiter is an empty character.
Here is an example Convert String into a List of string characters
void main() {
var str="welcome";
List<String> st=str.split('');
print(st);
}
Output:
[w, e, l, c, o, m, e]
You can also use trim
the string and split
the string
void main() {
var str="welcome john";
List<String> letterArray = str.trim().split("");
print(letterArray);
}
Here is an example Convert String int List of substrings with blank space delimiter.
void main() {
var str="welcome john";
List<String> st=str.split(' ');
print(st);
}
Output:
[welcome, john]
🧮 Tags
Recent posts
Julia examples - Variable Type Nim example - Convert String to/from the Int How to get length of an array and sequence in Nim? Nim environment variables - read, set, delete, exists, and iterate examples? How to convert from single character to/from string in Nim?Related posts