How do I remove newlines from a String in Dart?
How do I remove the newlines from a string in Dart?
For instance, I want to convert:
"hello\nworld"
to
"hello world"
Solution 1:
You can use replaceAll(pattern, replacement):
main() {
var multiline = "hello\nworld";
var singleline = multiline.replaceAll("\n", " ");
print(singleline);
}