Volatile file provider with recursive copy/delete, name validation and cycle protection; data does not survive a restart.
All file operations are asynchronous. Directory and file IDs are strings; null as parent/target denotes the root. Invalid names, name collisions, unknown IDs, duplicate IDs and cycles fail. Copy preserves contents, assigns new IDs and includes descendants. Remove deletes recursively. Without stored contents, download is empty; directory downloads are unavailable.
TxMemoryFileProvider
| Parameter | Type | Default | Meaning |
|---|---|---|---|
| entries | List<TxFileEntry> | const [] | Initial file/directory entries of the memory provider. |
| Member / type / return | Meaning |
|---|---|
Set<String> get capabilities | Supported file operations; controls visible actions. |
Future<List<TxFileEntry>> list(String? parentId, {TxCancellation? cancellation}) | Returns entries in the parent directory; null reads the root. |
Future<TxFileEntry> createDirectory(String? parentId, String name) | Creates a directory with a valid name unique within its parent. |
Future<void> rename(String id, String name) | Renames a file or directory; preserves its ID and parent. |
Future<void> move(String id, String? target) | Moves an entry to the target directory; cycles are rejected. |
Future<void> copy(String id, String? target) | Recursively copies an entry to the target directory, assigning new IDs. |
Future<void> remove(String id) | Removes the record or recursively removes a file/directory tree. |
Future<TxFileEntry> upload(String? parentId, TxFile file, {TxCancellation? cancellation}) | Uploads a file to the specified directory and returns its new entry. |
Future<Uint8List> download(String id) | Returns file contents; downloading a directory fails. |
import 'dart:typed_data';
import 'package:tecexpress/tecexpress.dart';
Future<void> example() async {
final provider = TxMemoryFileProvider();
final folder = await provider.createDirectory(null, 'Documents');
final file = await provider.upload(folder.id, TxFile.fromData(Uint8List.fromList([72, 105]), name: 'hello.txt'));
await provider.rename(file.id, 'renamed.txt');
await provider.copy(file.id, null);
await provider.rename(file.id, 'moved.txt');
await provider.move(file.id, null);
print(await provider.list(null));
print(await provider.download(file.id));
await provider.remove(folder.id);
}