MemoryStorageFile class final
In-memory file implementing both the sync and async interfaces.
Used by tests and by the crash matrix: "power cut" is simulated by copying the first N bytes into a fresh instance.
- Implemented types
Constructors
- MemoryStorageFile([int capacity = 4096])
-
Creates a file with room for
capacitybytes.
Properties
- appendCount ↔ int
-
Number of append calls.
getter/setter pair
- bytes → Uint8List
-
A read-only view of the current contents.
no setter
- flushCount ↔ int
-
Number of times the file was flushed.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- isClosed → bool
-
Whether the file has been closed.
no setter
-
length
→ Future<
int> -
Current logical length in bytes.
no setteroverride
- lengthSync → int
-
Current logical length in bytes.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
append(
Uint8List bytes) → Future< void> -
Appends
bytesat the end of the file.override -
appendSync(
Uint8List bytes) → void -
Appends
bytesat the end of the file.override -
close(
) → Future< void> -
Releases the file. Subsequent operations throw StateError.
override
-
closeSync(
) → void -
Releases the file handle. Subsequent operations throw StateError.
override
-
flush(
) → Future< void> -
Makes previously appended bytes durable.
override
-
flushSync(
) → void -
Makes previously appended bytes durable.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readAllSync(
) → Uint8List -
Reads the whole file as one buffer.
override
-
readAt(
int offset, int length) → Future< Uint8List> -
Reads exactly
lengthbytes starting atoffset.override -
readAtSync(
int offset, int length) → Uint8List -
Reads exactly
lengthbytes starting atoffset.override -
toString(
) → String -
A string representation of this object.
inherited
-
truncate(
int length) → Future< void> -
Cuts the file to
lengthbytes. Must not extend.override -
truncateSync(
int length) → void -
Cuts the file to
lengthbytes. Must not extend.override -
writeAllSync(
Uint8List bytes) → void -
Replaces the file contents with
bytes.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited