InMemoryFs class
In-memory VirtualFs backed by a Map (absPath -> UTF-8 content).
Used exclusively in tests via InstallContext.test so commands can be driven through their full lifecycle without touching the host filesystem. State persists across calls within a single instance and is fully isolated between instances (no shared static map).
Usage
final fs = InMemoryFs();
fs.writeAsString('/virtual/pubspec.yaml', 'name: app\n');
expect(fs.readAsString('/virtual/pubspec.yaml'), contains('name'));
- Implemented types
Constructors
- InMemoryFs()
- Creates an empty in-memory file store.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
snapshot
→ Map<
String, String> -
Read-only view of the underlying storage map. Exposed for tests that
need to assert on raw state without going through the VirtualFs
surface.
no setter
Methods
-
copy(
String fromAbs, String toAbs) → void -
Copies
fromAbstotoAbs. Auto-creates any missing parent directories at the destination. OverwritestoAbsif present.override -
delete(
String absPath) → void -
Deletes the file at
absPath. Silent no-op when the file is missing (idempotent, mirrorsrm -fsemantics).override -
exists(
String absPath) → bool -
Returns
truewhen a file (not directory) exists atabsPath.override -
listSync(
String absDir) → List< String> -
Returns the immediate filenames inside
absDir. Non-recursive. Subdirectory names and nested files are excluded.override -
md5(
String absPath) → String -
Returns the lowercase hex md5 digest of the file content at
absPath. Computed on demand each call (no caching) so the result reflects the current on-disk bytes.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readAsString(
String absPath) → String -
Reads the file at
absPathand returns its UTF-8 string content.override -
rename(
String fromAbs, String toAbs) → void -
Atomic POSIX-style rename of
fromAbstotoAbs. OverwritestoAbswhen present (matchesrename(2)semantics used by InstallTransaction.commit's.tmpswap).override -
toString(
) → String -
A string representation of this object.
inherited
-
writeAsString(
String absPath, String content) → void -
Writes
contenttoabsPath(UTF-8). Auto-creates any missing parent directories. Overwrites the file when it already exists.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited