Reputation: 463
I want to split some string and to contain each line in separate element in array. I use this code for reaching my goal:
List _masForUsing;
_masForUsing = new List(numberOfLines);
void gpsHelper(String text, int count){
for(int i =0; i<count;i++){
_masForUsing[i] = text.split("\\r?\\n");
}
print(_masForUsing[2]);
}
But when I am truying to evoke the third element of array, it just show full my string. Please help, me :)
This is example of String:
real time: 23-09-2019, 23:08:55, Mon system time: 5362 gps coordinates: 55.376538; 037.431973; gps satellites: 3; gps time: 20:09:02; gps date: 23.09.19; temperature: 19 *C humidity: 35 % dust: 1 zivert: 21
Upvotes: 8
Views: 6444
Reputation: 11651
Is this what you want?
void gpsHelper(String text) {
List _masForUsing = text.split("\n");//this one here
print('third string is ${_masForUsing[2]}');
}
Upvotes: -3
Reputation: 6277
Use Dart's built in LineSplitter
, It is system independent.
void gpsHelper(String text) {
LineSplitter ls = new LineSplitter();
List<String> _masForUsing = ls.convert(text);
//print(_masForUsing[2]); // gps coordinates: 55.376538; 037.431973;
}
Upvotes: 22