Skip to main content

dart_smb2 0.5.1 copy "dart_smb2: ^0.5.1" to clipboard
dart_smb2: ^0.5.1 copied to clipboard

Dart SMB2/3 client built on libsmb2, with listings, streaming reads, atomic downloads, uploads, copies, watches and cancellation. macOS, Windows, Linux, iOS and Android.

0.5.1 29-11-2026 #

libsmb2-r15 #

All platforms

  • A large directory lists in far fewer round trips: each request asks for as much as the server negotiated.
  • On SMB 3.1.1, signing uses AES-GMAC when the server offers it, several times faster than AES-CMAC.
  • A request that times out half written closes the connection, instead of corrupting the next one.

All platforms #

Added

  • Smb2Pool.connect takes interactiveWorkers: workers kept for the calls of one round trip, so a stat no longer waits behind a transfer.

Changed

  • streamDirectory, copyTree and the recursive rmdir list several directories at once, one per worker that serves them, in the same order.
  • copyTree copies as many files at once as the pool has workers for transfers.
  • With more than one worker, streamFile and downloadToFile keep two reads queued: at most three chunks are in memory.
  • readFileRange past the end of the file returns what is left, instead of failing with invalidParam for a large length.
  • Opening a file to read it no longer asks the server for its size apart: one round trip fewer.
  • copy checks the source and the destination at the same time.
  • The bundled libsmb2 is libsmb2-r15. A libsmb2 of your own, set through hooks.user_defines, must be a build of libsmb2-scripts at libsmb2-r15.

0.5.0 21-11-2026 #

libsmb2-r14 #

All platforms

  • Built from upstream master of 20-11-2026: libsmb2 7.0.0, upstream's first release since 6.2, and the fixes after it. Upstream now carries the fixes of r12 and r13 that were sent to it from libsmb2-scripts.
  • A server that negotiates a read size of 0 can no longer make a read write past the end of the caller's buffer.
  • A signed compound reply that arrives over several reads of the socket has the signature of each of its parts checked.
  • Closing a connection frees the files and directories still open on it: a client dropped without disconnect() no longer leaks them.
  • A write reply that claims more bytes than were sent fails, instead of moving the offset past data that was never written.
  • The read and write sizes a server negotiates are capped at 8 MiB, so a forged one no longer becomes the size of a buffer.
  • A directory listing whose entries overlap fails, instead of filling memory with entries a few bytes apart.
  • A path longer than a CREATE request can name fails, instead of opening the root of the share.

All platforms #

Changed

  • The bundled libsmb2 is libsmb2-r14. A libsmb2 of your own, set through hooks.user_defines, must be a build of libsmb2-scripts at libsmb2-r14.
  • A connect whose session setup the server never completes fails with accessDenied, as other failed session setups do; it was auth.

0.4.1 15-11-2026 #

libsmb2-r13 #

All platforms

  • A server can no longer stop the app with oplock break notifications nobody asked for: libsmb2 acknowledged each one, and the reply to the acknowledgement made it call address 0. No memory was written.
  • A reply that stops arriving after its header, during the connect too, fails with timeout instead of keeping the call waiting for ever. A large reply that keeps arriving is not cut.
  • A connect whose session setup the server never completes fails after sixteen legs.
  • After a reply that could not be parsed, closing the connection no longer runs the callbacks of the requests still queued on data freed long before.
  • A call on a connection libsmb2 has closed fails at once with connection, not after its timeout.
  • On SMB 3.1.1 a logon the server maps to guest reaches a share that allows guests: its TREE_CONNECT is no longer signed with a key the session does not have.

All platforms #

Changed

  • The bundled libsmb2 is libsmb2-r13. A libsmb2 of your own, set through hooks.user_defines, must be a build of libsmb2-scripts at libsmb2-r13.

Fixed

  • Smb2Client.listShares() and Smb2Pool.listSharesOn() take seal, signing and version, as connect() does: the share list travelled unsigned unless the server asked otherwise.
  • A server that cannot sign what signing: true requires fails with accessDenied, as a server that cannot encrypt does; it was inUse, which a caller retries.
  • A reply that fails its signature while connecting fails with connection, as it does afterwards; it was invalidParam.

0.4.0 14-11-2026 #

Contributions #

libsmb2-r12 #

All platforms

  • A read or write at the end of the file reports 0 bytes, never a field of the server's error reply.
  • A read or write whose request cannot be built no longer leaks its call data.
  • unlink and mkdir report the first failure of their request, with its NT status.
  • A time the server does not keep, or one before 1970, is 0 instead of a date in the year 60056.
  • smb2_open2(), patched in, opens one file so that it can be renamed or removed while it is open.
  • Every library is built with a stack protector and _FORTIFY_SOURCE=2.

Linux and Android

  • The libraries are linked with full RELRO.

All platforms #

Breaking

  • A libsmb2 of your own, set through hooks.user_defines, must be a build of libsmb2-scripts at libsmb2-r12. See MIGRATION.md.
  • Smb2Client.readFileChunked() fails with io when the file shrinks while it is read, where it stopped early without an error.

Changed

  • A client that has watched keeps its connection until disconnect(): neither the garbage collector nor the end of its isolate frees it.
  • The temporary files of uploadFile(), copy() and copyTree() end in 16 hex digits instead of 8.

Fixed

  • An isolate that ends while its Smb2Client is watching no longer aborts the whole app.
  • uploadFile(), copy() and copyTree() finish after the server stopped answering in the middle, and leave no temporary file: their rename failed with inUse.
  • A reply that counts more bytes than the read or write asked for fails with io instead of reading past the buffer.
  • Smb2Stat gives a time the server does not keep as the Unix epoch.
  • A second Smb2Pool.disconnect(), made while the first is closing the workers, completes with it instead of at once.
  • A pool with timeout: Duration.zero no longer fails to connect, or to reconnect, after 15 seconds.
  • uploadFile() reports a missing folder of the local file as notFound on Windows too.
  • Smb2CancelToken.cancel() reaches every call that uses the token, also when one of them throws.
  • A download that fails in the build hook closes its file, and a failed unzip leaves no folder behind.

Docs #

  • readFileChunked() says when it closes its handle.

0.3.0 8-11-2026 #

libsmb2-r11 #

All platforms

  • libsmb2 is upstream master of 7-11-2026 (a52c157).
  • A zero-length read or write no longer fails.
  • A copychunk error reply is read in the format the server sent it.
  • Lease and oplock breaks and their acknowledgements are encoded and decoded right.
  • Signing and encryption go through OpenSSL 3.5's libcrypto, linked in statically.
  • A sealed session on SMB 3.1.1 uses AES-256-GCM or AES-128-GCM, as the server picks, instead of AES-128-CCM.
  • Each library carries libcrypto, and is five to thirteen times larger.
  • smb2_rename2(), patched in, lets a rename replace an existing file.
  • smb2_scripts_release(), patched in, returns the release the library was built as.

Windows

  • A directory can be opened as a handle, which a watch needs.

All platforms #

Breaking

  • The names deprecated in 0.2.0 are gone: Smb2Client.open(), Smb2Handle.isValid, openFileHandle, openFileHandleWrite, readHandle, writeHandle, fsync and ftruncate of Smb2Client, timeoutSeconds:, the Smb2Pool.listShares() instance method, isCanceled:, Smb2PoolHandle.closed and refreshFinalizer(), Smb2Exception.isConnectionError and errorCode, Smb2ErrorType.isConnectionError, fileNotFound and classify().
  • Smb2Pool.streamWrite() returns the bytes written, as a Future<int>.
  • A libsmb2 of your own, set through hooks.user_defines, must be a build of libsmb2-scripts at libsmb2-r11: with any other, or upstream libsmb2, connecting fails with an Smb2Exception of type notSupported. See MIGRATION.md.

Added

  • Smb2Pool.watch() streams the changes to a directory as Smb2ChangeEvents, with Smb2ChangeAction and Smb2ChangeFilter.
  • A watch of Smb2Pool runs on a connection of its own, which reconnects by itself.
  • Smb2Client.watch() returns an Smb2Watcher.
  • Ending a watch waits for its request in flight, up to about 15 seconds when the server hangs.
  • rename(overwrite: true) in Smb2Pool and Smb2Client replaces an existing file in one request.
  • link() makes a hard link and symlink() a symbolic link, in Smb2Pool and Smb2Client.
  • mkdir(recursive: true) and rmdir(recursive: true) in Smb2Pool work like mkdir -p and rm -r.
  • rmdir(recursive: true) refuses the share root, stops at the first failure, and never goes through a link to a directory that Samba follows.
  • Smb2Pool.streamDirectory() lists a directory as a stream, and a whole tree with recursive, where a link never makes a loop.
  • Smb2Stat.fileId, the server's id of the file.
  • Smb2Pool.copy() and copyTree(), with progress.
  • Smb2Pool.uploadFile(), the counterpart of downloadToFile().
  • streamWrite() takes onProgress and length.

Changed

  • The build hook needs code_assets ^2.2.0.
  • When downloadToFile() cannot write the local file, or uploadFile() cannot read it, Smb2Exception.path is that local path instead of the remote one.

Docs #

  • The guides cover watches, links, copies, trees, uploads, renames that replace, and encryption.
  • The guides say what Windows 11 24H2 and Windows Server 2025 require: signed sessions, and no guest logon.
  • NOTICE lists OpenSSL, whose Apache-2.0 licence ships with the libraries.
  • Smb2Client explains why a request in flight cannot be cancelled.

0.2.5 5-11-2026 #

libsmb2-r10 #

All platforms

  • A request on an encrypted session is never sent in the clear.
  • A reply longer than the read asked for, or for another command, is refused.
  • The NTLM logon no longer sends uninitialised memory to the server.

Android

  • A logon with a password and no user no longer reads out of bounds on armeabi-v7a.

0.2.4 2-11-2026 #

Docs #

  • A shorter README, with the guide moved to topics of the API reference.

0.2.3 22-10-2026 #

Docs #

  • The README and MIGRATION.md ask for Flutter 3.47 in an app, not 3.38: on an older Flutter, pub get cannot resolve the build hook's dependencies.

0.2.2 21-10-2026 #

Contributions #

  • @freeKC: reported that a user with an empty password logged on anonymously, and proposed the fix (#4).

Breaking #

  • password: '' with a user is a logon as that user: for an account that has a password it fails with auth, where it logged on anonymously.

Fixed #

  • A user with an empty password logs on as that user, so a server that refuses anonymous logons, such as the Freebox Server, can be reached (#4). Without a user, an empty password still logs on anonymously.

Docs #

  • Smb2Client.connect, listShares and Smb2Pool.connect describe the credentials: no user, or a null password, means an anonymous logon, not guest.

0.2.1 13-10-2026 #

Docs #

  • Changes to the README.

0.2.0 13-10-2026 #

A revision of the whole package. See MIGRATION.md for the changes to make in an app.

Breaking #

  • dart_smb2 is a plain Dart package: a build hook bundles libsmb2, and the Flutter plugin (Gradle, CocoaPods, SwiftPM, CMake) is gone. It needs Dart 3.10, Flutter 3.38 in an app, and minSdk 24 on Android, which the hook now checks.
  • Smb2Exception takes named arguments (type:, ntStatus:, errno:, path:, cause:) and is final.
  • Smb2ErrorType gains notEmpty, isADirectory, inUse, notSupported, state and cancelled, and fileNotFound becomes an alias of notFound: the values, their order and toString() change. A closed pool or handle and a client that is not connected report state, not unknown.
  • Smb2Exception.errno and the deprecated errorCode are the errno of the failed call (for an open or a listing, of the server's status), and null for a transport failure: 0.1.x read whatever status an earlier call had left.
  • Smb2Pool.downloadToFile() takes the destination as a String path and writes it atomically.
  • Smb2Client.listShares() is static, and Smb2Client methods throw state on a closed or foreign handle.
  • mkdir, rmdir, deleteFile and rename are not repeated after a network failure.
  • rmdir of a file fails with notADirectory (it deleted the file), deleteFile of a directory, or of a link to one, with isADirectory (it deleted an empty one, and did nothing on one with entries), and truncate of a directory with isADirectory (it did nothing).
  • Smb2Pool.connect(workers: 0) throws invalidParam.
  • Smb2Stat requires accessed and changed, the public types are final, Smb2PoolHandle no longer exposes worker, id and markClosed(), and the Smb2File constructor is internal.

Added #

  • Smb2CancelToken, taken by every call on a connected Smb2Pool except closeHandle(), disconnect() and the deprecated listShares().
  • Smb2Exception.isNetworkFailure, isTransient, isNotFound, isCancelled, isAuthError, ntStatus and errno.
  • Smb2ErrorType.fromFailure(), which classify() now calls.
  • Smb2Stat.accessed, changed, attributes and isHidden, and times to the microsecond.
  • Smb2ShareInfo.remark and Smb2ShareType.temporary.
  • Smb2Client.maxReadSize and maxWriteSize.
  • Smb2Pool.openFileWrite(truncate:), isClosed and defaultChunkSize.
  • hooks.user_defines.dart_smb2.libsmb2, to bundle a local libsmb2.
  • A NOTICE on the LGPL-2.1 libsmb2 that apps bundle.

Changed #

  • The error type comes from the server's NT status and from per-platform errno tables: Windows errors were misread. A status counts only when the server answered this call with it.
  • A host name that does not resolve and libsmb2's generic failures are connection errors; a server out of resources is inUse; a read-only share is accessDenied.
  • streamFile() reads one chunk ahead, 4 MiB by default; downloadToFile() writes at the disk's pace.
  • Calls go to the least busy worker, and the workers connect in parallel.
  • A cancelled call returns at once, also while it waits for a reconnect or a slot.
  • disconnect() aborts a reconnect in progress instead of waiting for its connect.
  • Leaving or cancelling a stream, a download or withFile() never waits behind a read stuck on the network.
  • A worker that dies is reconnected at once. While a slot cannot reconnect, the other workers serve its calls and it retries in the background; after the server refuses the credentials, the pool tries one login every 5 minutes.
  • Reads reach the calling isolate in native buffers, without a copy.
  • streamWrite() repeats a chunk after a reconnect.
  • Paths drop leading slashes and take backslashes.
  • timeout: Duration replaces timeoutSeconds:, which is deprecated.
  • Smb2ErrorType.fileNotFound and classify(), Smb2Exception.isConnectionError and errorCode, and Smb2PoolHandle.closed and refreshFinalizer() are deprecated: use notFound and fromFailure(), isNetworkFailure and errno, and isClosed.
  • Smb2Client.open(), openFileHandle(), openFileHandleWrite(), readHandle(), writeHandle(), fsync() and ftruncate() are deprecated: use Smb2Client(), openFile(), openFileWrite(), readFromHandle(), writeToHandle(), fsyncHandle() and ftruncateHandle().
  • isCanceled: on streamFile() and downloadToFile(), and the instance Smb2Pool.listShares(), are deprecated: use cancelToken: and Smb2Pool.listSharesOn().

Fixed #

  • Closing a handle twice freed it twice and aborted the process.
  • readFileRange() came back short, and readFileChunked() skipped data, for reads above the server's MaxReadSize; a read of 4 GiB or more failed.
  • A handle on a worker replaced by a reconnect failed for good.
  • Smb2Pool.connect() hung when a worker isolate died before connecting, and reported unknown for wrong credentials.
  • disconnect() during a reconnect left a worker and its session alive, or threw an unhandled RangeError.
  • downloadToFile() emptied the destination when the remote file was missing.
  • A plain dart test ran the integration suites, which failed now and then.

Build #

  • libsmb2 is upstream master of 11-10-2026 (e94eee9), which hardens the handling of signed and encrypted replies.
  • stat tells a symbolic link from other reparse points, such as cloud files, which it used to report as links.
  • rmdir and unlink check what they remove, truncate refuses a directory, and a request that times out before it is sent fails with timeout instead of hanging.
  • Pools that connect and disconnect at once no longer race on libsmb2's context list.
  • The Linux libraries need glibc 2.25 or later instead of 2.38, and every library is stripped and exports libsmb2's API only.
  • The binaries are built and verified on GitHub's runners; each release carries manifest.json, SHA256SUMS and the LGPL texts.
  • The build hook stops a download that hangs, retries it, and names the user define to set when it fails.
  • CI analyzes the package, tests it on Linux, macOS and Windows and against Samba, builds an app for every platform, and runs test_app/ on Android, iOS, Linux, macOS and Windows.
  • The example is one Dart file instead of a Flutter app.
  • Updated binaries to libsmb2-r9 across all platforms.

0.1.3 19-09-2026 #

Contributions #

  • @laurentiugh: reported the crash on a timed-out open, traced it to the double free in the bundled libsmb2 and verified the fix against a locally patched build (#3).

Build #

  • Opening a file or listing a directory on a share that stopped answering no longer kills the app with a native abort, which Dart cannot catch. The call now throws Smb2Exception with Smb2ErrorType.timeout once timeoutSeconds elapses, and Smb2Pool reconnects as it does for any other connection error.
  • Every file open no longer leaks a few bytes of native memory.
  • Updated binaries to libsmb2-r8 across all platforms.

0.1.2 24-08-2026 #

Security #

  • Windows now draws the NTLMv2 client challenge, the SMB 3.1.1 preauth salt and the AES-CCM nonce from the system CSPRNG (CNG BCryptGenRandom) instead of rand().

Build #

  • Rebased the bundled libsmb2 to upstream master 2026-08-14, picking up the August 2026 security hardening series.
  • Share enumeration now uses upstream's rewritten minimal DCE/RPC; the previous code's unaligned accesses were the prime suspect for the arm32 crash in #2.
  • Updated binaries to libsmb2-r7 across all platforms and regenerated the ffigen bindings against the r7 headers.
  • The libsmb2-scripts build infrastructure is now public and patch-based — the corresponding source for the LGPL-2.1 libsmb2 binaries (#2).

0.1.1 19-07-2026 #

Added #

  • setFileTimes(path, {modified, accessed}) on both Smb2Client and Smb2Pool — set the remote last-modified and/or last-accessed time of a file or directory. Fields left null are unchanged on the server. Useful for file manager, backup, and sync apps that preserve local timestamps on upload (#1).

Build #

  • Patched libsmb2 with a new smb2_utimes / smb2_utimes_async API (compound CREATE + SET_INFO FILE_BASIC_INFORMATION + CLOSE, modeled on smb2_truncate). Timestamps travel as fixed-width microseconds-since-epoch scalars, so the FFI ABI is identical on every platform including 32-bit Android.
  • Updated binaries to libsmb2-r6 across all platforms.

0.1.0 28-05-2026 #

Changed #

  • General refactor of the code.
  • Rewrote the FFI layer with ffigen and simplified the internals; temporary native memory is now freed automatically.
  • Smb2Client.open() no longer takes a path; the native library already loads automatically.

Removed #

  • CachedSmb2Pool and built-in caching. The pool no longer caches stat / listDirectory — cache at your own layer if you need to.

Fixed #

  • listDirectory and listShares now work correctly on 32-bit Android.
  • readlink handles long symlink targets correctly.
  • File paths containing NUL characters are rejected instead of being silently cut short.
  • Pool operations no longer hang if a worker dies mid-request — they fail fast and reconnect.
  • Interrupted downloads now raise an error instead of finishing short and silent.
  • Several handle and reconnect edge cases under heavy concurrency are handled cleanly.

0.0.8 25-05-2026 #

Fixed #

  • General minor fixes.

0.0.7 25-05-2026 #

Docs #

  • Branding realignment with the rest of the libraries.

Build #

  • Improvements to Swift Package Manager on both iOS and macOS.
  • iOS and macOS now ship a dynamic xcframework.
  • Bumped minimum deployment targets to iOS 15.0 and macOS 12.0.
  • Added Android armeabi-v7a (32-bit ARM), Linux aarch64 and Windows arm64 binaries.
  • Updated libs to libsmb2-r5 across all platforms.

0.0.6 24-04-2026 #

Added #

  • Smb2Pool.withFile(path, body, {knownSize}) and scoped Smb2File — opens a read handle, runs the callback, guarantees closeHandle on any exit (exception, early return, cancellation). Replaces the openFileWithSize + readFromHandle + closeHandle boilerplate at every call site.
  • Smb2Pool.downloadToFile(path, File destFile, {chunkSize, onProgress, isCanceled}) — one-call download of an SMB file to a local File streaming through a single persistent handle.
  • onProgress(received, total) and isCanceled() callbacks to Smb2Pool.streamFile. Cancellation throws Smb2Exception; the handle is always closed.
  • Finalizer on Smb2PoolHandle that best-effort-closes handles leaked by the caller. Safety net only — prefer explicit closeHandle or withFile for deterministic cleanup.

Fixed #

  • streamFile was implemented on top of readFileRange, which does open + pread + close per chunk — a 50 MiB read in 1 MiB chunks meant 50 SMB2 Create/Close pairs on the wire. It now uses a single persistent handle (1 Create + N Reads + 1 Close) and chunks at libsmb2's server-negotiated MaxReadSize.
  • Smb2Pool.fsyncHandle and ftruncateHandle now go through the auto-reconnect path. A disconnect mid-operation previously surfaced a raw worker-send failure instead of a clean reconnect + retry.
  • closeHandle is idempotent; calling it twice on the same handle is a no-op (previously it would fail with "Invalid handle" on the second call).

Removed #

  • Smb2Isolate. It duplicated Smb2Pool(workers: 1) with a divergent error format and no auto-reconnect. Use Smb2Pool.connect(..., workers: 1) instead.

Docs #

  • Rewrote the README around Smb2Pool as the default entry point. New sections: Scoped File Access (withFile), Download to File, Low-Level File Handles.

Example #

  • New demo cards in the example app for withFile, downloadToFile, openFileWithSize, fsyncHandle, and an Error Classification card that exercises stat / exists / deleteFile on missing paths and reports the resolved Smb2ErrorType. Wired onProgress into the streamFile card.

Build #

  • Patched libsmb2's completion callbacks (create_cb_1, fstat_cb_1, getinfo_cb_3, trunc_cb_3, rename_cb_3, ftrunc_cb_1) to populate the NT error on the context via smb2_set_nterror. Previously stat/exists/mkdir/rmdir/deleteFile/rename/truncate/ftruncate silently surfaced as Smb2ErrorType.unknown with errno=0 and an empty message on any failure — so exists() could not detect fileNotFound and mkdir() could not detect alreadyExists.
  • Updated binaries to libsmb2-r4.

0.0.5 12-04-2026 #

Fixed #

  • Incorrect lib version in .podspec.

0.0.4 12-04-2026 #

Fixed #

  • Linux libsmb2.so was built as ARM64 (Docker default on Apple Silicon) and failed to load on x86_64 hosts; build now forces --platform=linux/amd64.
  • Windows libsmb2.dll had unbundled MinGW runtime dependencies (libgcc_s_seh-1.dll, libwinpthread-1.dll); now statically linked with -static -static-libgcc.
  • Smb2Exception: Poll failed on Android and Linux during connect — patched libsmb2 sync.c to retry poll() on EINTR (signals from ART/Dart VM were aborting the syscall).

Build #

  • Updated binaries to libsmb2-r3.

0.0.3 12-04-2026 #

Fixed #

  • Transport failures (POLLHUP, POLLERR, socket read/write errors, connect failures, lost tree-id after server-side idle teardown, …) now classify as Smb2ErrorType.connection instead of unknown.

0.0.2 09-04-2026 #

Added #

  • Write operations, write handles, file management (mkdir, rmdir, deleteFile, rename, truncate), filesystem info (statvfs, readlink, echo, fsync, ftruncate, exists), security options (seal, signing, version), Smb2Version enum, Smb2StatVfs type.

Fixed #

  • libsmb2 thread safety mutex, zero-copy isolate transfers, Smb2Isolate.disconnect() graceful shutdown, streamWrite no retry on failure, unified error encoding, write loop infinite hang, fileSize() now throws, truncate() negative length validation, allocator consistency, listdir capacity overflow, TransferableTypedData fresh per retry.

Example #

  • Flutter app with server management, 12 read demo cards, 10 write demo cards.

Build #

  • Updated binaries to libsmb2-r2.

0.0.1+2 08-04-2026 #

Fixed #

  • AndroidManifest.xml.

0.0.1+1 08-04-2026 #

Fixed #

  • Minor fixes.

0.0.1 07-04-2026 #

Added #

  • Initial release.
8
likes
160
points
12.3k
downloads
screenshot

Documentation

API reference

Publisher

verified publisherales-drnz.com

Weekly Downloads

Dart SMB2/3 client built on libsmb2, with listings, streaming reads, atomic downloads, uploads, copies, watches and cancellation. macOS, Windows, Linux, iOS and Android.

Repository (GitHub)
View/report issues

Topics

#cross-platform #smb2 #smb3 #samba #libsmb2

License

BSD-3-Clause (license)

Dependencies

code_assets, crypto, ffi, hooks, meta

More

Packages that depend on dart_smb2