fs_shim
2.8.0, released 3 days ago by tekartik.com
Portable file system API working identically on io, web (IndexedDB/OPFS) and memory.
WASM-ready
What it does
Provides an asynchronous subset of dart:io File, Directory, and Link behind a FileSystem abstraction. Enables identical file system code to run on native IO, browser storage, and in-memory for testing.
AI-written summary of version 2.7.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need file system operations that work on both Flutter mobile/desktop and web browsers.
- You want to unit test file-dependent code easily using an in-memory file system.
Skip it when
- You require synchronous file I/O (browser storage is strictly asynchronous).
- You need advanced OS features not mapped in dart:io (e.g., watching file changes or process execution).
Strengths
- Consistent asynchronous API across IO, web (IndexedDB and OPFS), and memory.
- Great for writing testable code with in-memory files.
- Drop-in wrapper or replacement for dart:io file classes via fs_io.dart.
Weaknesses
- Asynchronous API only; no synchronous methods are available.
- OPFS backend does not support links or random access.
- Web storage is bound by browser quotas.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
import 'package:fs_shim/fs_shim.dart';
Future<void> main() async {
final fs = fileSystemDefault;
final dir = fs.directory(fs.path.join(fs.currentDirectory.path, 'demo'));
await dir.create(recursive: true);
final file = dir.file('hello.txt');
await file.writeAsString('Hello world!');
print(await file.readAsString());
await dir.delete(recursive: true);
}Alternatives
Packages that do the same job and could replace fs_shim.
Works with
Packages commonly used together with fs_shim: ones it builds on, ones built on it, and its own family.
- synchronizedfs_shim depends on itLock mechanism to prevent concurrent access to asynchronous code.
- sembastfs_shim depends on itA NoSQL persistent embedded document-based database for Dart and Flutter.
- idb_shimfs_shim depends on itCross-platform IndexedDB implementation for Dart and Flutter.
- sqflite_commonSame familyDart wrapper on SQLite providing the common API for sqflite and desktop FFI implementations.
- sqflite_common_ffiSame familyFFI-based implementation of sqflite for desktop platforms and unit tests.
- process_runSame familyRun shell scripts and locate executables across Linux, Windows and macOS.
- sqflite_common_ffi_webSame familySqflite web implementation using sqlite3 ffi and sqlite3 wasm.
- sembast_webSame familyNoSQL persistent embedded database for the Web on top of IndexedDB.