dart - Removing empty lines while reading a file in Dartlang -
i have file like:
a b c d
both readaslines()
, readasstring() + string.split('\n')
give me:
[a, b, , , c, d]
what smartest way get?
[a,b,c,d]
one possibility be:
import 'dart:io'; main() { file f = new file('test.txt'); f.readaslines().then((list<string> lines) { print(lines.where((string s) => s.isnotempty)); }); }
Comments
Post a Comment