You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MemoryFile.readAsLines/readAsLinesSync behave differently than normal File when there is a trailing newline in the file:
import'package:file/file.dart';
import'package:file/memory.dart';
voidmain() {
final fs =MemoryFileSystem();
final f = fs.file('test.txt');
f.writeAsStringSync('\n');
final lines = f.readAsLinesSync();
print('${lines.length}'); // Prints 2.
}
If using LocalFileSystem or dart:io's File instead, readAsLinesSync() will return a List<String> with only one element.
readAsBytes indicates that the file was written correctly, so the problem is in readAsLinesSync.
The text was updated successfully, but these errors were encountered:
* Fix MemoryFile.readAsLines to behave more like File.readAsLines
Fix `MemoryFile.readAsLines` to behave more like `File.readAsLines`.
A final newline should not add an empty string as the last element of
the returned `List`.
Fixes#142.
* Make RecordingFile.readAsLines/readAsLinesSync always record a final newline
Fixes#146.
MemoryFile.readAsLines
/readAsLinesSync
behave differently than normalFile
when there is a trailing newline in the file:If using
LocalFileSystem
ordart:io
'sFile
instead,readAsLinesSync()
will return aList<String>
with only one element.readAsBytes
indicates that the file was written correctly, so the problem is inreadAsLinesSync
.The text was updated successfully, but these errors were encountered: