LineFile class

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

Constructors

LineFile(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 Future<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}) Future<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() Future<void>
Close and flushes the file to disk.
flush() Future<void>
Flushes the contents of the file to disk.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open() Future<void>
Opens the file for random access.
read({String? lineDelimiter}) Future<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() Stream<String>
Returns a Stream with the contents of the file as Strings.
toString() String
A string representation of this object.
inherited
truncate() Future<void>
Truncates the file to zero bytes in length.
write(String line, {String? newline}) Future<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