Skip to content
All work

library

dart_smb2

Read, write and stream files from network shares on every platform Flutter runs on. FFI bindings to a patched libsmb2, an isolate worker pool that reconnects transparently, and prebuilt native binaries for five operating systems from a reproducible build pipeline.

GitHub stars
7
pub.dev likes
6
pub points
160/160
Downloads /30d
1.7K
The dart_smb2 example app browsing a network share on a phone

What it is

A Dart client for SMB2/3 file shares (the protocol used by Windows shares and most home NAS devices), with one API on desktop and mobile, built on the libsmb2 C library.

Design

  • FFI, synchronous at the core: bindings to libsmb2 via dart:ffi, with native binaries bundled for every target.
  • Smb2Pool on top: requests are spread across N isolate workers, off the main isolate. Dropped connections are re-established and the failed operation is retried automatically.
  • Safe handles: withFile(path, body) guarantees the handle is closed on every exit path, with a Finalizer as a safety net for leaked handles.
  • Semantic errors: one Smb2Exception hierarchy with an Smb2ErrorType enum instead of raw NTSTATUS codes.
final pool = await Smb2Pool.connect(
  host: '192.168.1.100',
  share: 'Files',
  user: 'user',
  password: 'pass',
);

final entries = await pool.listDirectory('Documents/Projects');

await pool.downloadToFile(
  'Music/song.flac',
  File('/tmp/song.flac'),
  onProgress: (received, total) => print('${(received / total * 100).toStringAsFixed(1)}%'),
);

Native builds

The binaries come from libsmb2-scripts: a pinned upstream libsmb2 with patches, cross-compiled for Android, iOS, macOS, Windows and Linux on multiple architectures. The same repository doubles as the LGPL corresponding-source offer for every shipped binary.

Example app

Server listBrowsing a shareReading a fileWriting a file

Next project

dart_jellyfin & dart_plex

Typed Dart clients for Jellyfin and Plex Media Server.