Skip to content
pubscout

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
$ flutter pub add fs_shim
Source repository

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.

  • file

    If you only need a pluggable file system abstraction for dart:io without web (IndexedDB/OPFS) or memory-specific implementations built in.

Works with

Packages commonly used together with fs_shim: ones it builds on, ones built on it, and its own family.