LineFile class

Provide s collection of methods to make it easy to read/write a file line by line.

Constructors

LineFile.new(String path, {FileMode fileMode = FileMode.writeOnlyAppend})
If you instantiate FileSync you MUST call close.

Properties

hashCode int
The hash code for this object.
no setterinherited
length int
Returns the length of the file in bytes The file does NOT have to be open to determine its length.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

append(String line, {String? newline}) → void
Appends the line to the file Appends newline after the line. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator.
close() → void
Close and flushes the file to disk.
flush() → void
Flushes the contents of the file to disk.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open() → void
Opens the file for random access.
read({String? lineDelimiter}) String?
Reads a single line from the file. lineDelimiter the end of line delimiter. May be one or two characters long. Defaults to the platform specific delimiter as defined by Platform().eol.
readAll(bool handleLine(String)) → void
Read file line by line.
toString() String
A string representation of this object.
inherited
truncate() → void
Truncates the file to zero bytes in length.
write(String line, {String? newline}) → void
Truncates the file to zero bytes and then writes the given text to the file. If newline is null or isn't passed then the platform end of line characters are appended as defined by Platform().eol. Pass null or an '' to newline to not add a line terminator.

Operators

operator ==(Object other) bool
The equality operator.
inherited