Reading a file in dart and split the string has different results in console that in vscode
Your code are dependent on the newline format of your txt file. I will recommend you are using the LineSplitter
class from dart:convert
to split your lines.
The problem is that Windows newlines contains both '\n'
and '\r'
but you are only removing the '\n'
part. '\r'
are essential meaning the terminal should set the cursor back to the beginning of the line.
You can read this like a typewriter where you first move the head back and set move the paper to the next line. And can read a lot more about is topic here: https://en.wikipedia.org/wiki/Newline
The purpose of the LineSplitter
class is to abstract all of this logic and get some behavior which will work on all platforms.
So import dart:convert
and change this line:
var aux = str.split("\n");
Into:
var aux = LineSplitter.split(str).toList();