dartvex_flutter 0.4.2
dartvex_flutter: ^0.4.2 copied to clipboard
Flutter widgets for Convex — ConvexProvider, QueryBuilder, MutationBuilder, and more. Reactive UI powered by Dartvex.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased] #
0.4.2 - 2026-11-20 #
Changed #
- Documentation: "The Dartvex ecosystem" table lists
dartvex_auth2_convex, the Convex Auth (@convex-dev/authv2) adapter, published as 0.1.0. - Requires
dartvex^0.4.2, which includes the 0.4.1 fix: a transient network outage no longer signs the user out.
0.4.0 - 2026-11-20 #
Added #
FakeConvexAuthClient<T>: a scriptableConvexAuthClientfor tests (onLogin,onLoginFromCache,onLogout,emit, call counters), with function calls and connection state served by aFakeConvexClient.ConvexRuntimeWatch.watch<T>(name, args, {decode, skipCached})onConvexRuntimeClient(ConvexProvider.of(context),FakeConvexClient): a decodedStream<T>of a live query that unsubscribes on cancel.- Re-exports
AuthState,AuthLoading,AuthAuthenticated,AuthUnauthenticated,AuthSessionEndedErrorandConvexAuthClient, so aConvexAuthBuilderswitch compiles with thedartvex_flutterimport alone.
Changed #
- With
ConvexClientRuntime, the warm seed of a new subscription (a result kept after an earlier subscription to the same query was cancelled) is now reported withConvexQuerySource.cacheinstead ofremote; the server's result follows asremote.
Fixed #
ConvexAssetCache.clear()also removes the files of downloads that were still in flight when it was called, or that started while it was running (it waits for them), whenever they finish, so a file of the previous user can no longer land in the cache after a sign-out purge. Await it before the next user's screens load: a file they download during the purge is removed with the rest. The docs ofConvexAssetCacheandConvexCachedImagenow say that entries are not tied to a user and how to isolate private files (clear on user change, or a per-usercacheKey).FakeConvexSubscription.cancel()called while the subscription delivers an event (for example afterawait subscription.stream.firstthroughfunctionCaller) no longer throws "Cannot fire new event".
0.3.0 - 2026-11-05 #
Added #
PaginatedQueryBuilder.errorBuilder(PaginatedQueryErrorWidgetBuilder) receives the error object of a failed query — the page's server error or a decode failure — plus the items loaded so far and aretrycallback that restarts the query. The existingbuildersignature is unchanged.ConvexDecodeException(error, stack trace and raw value), used byConvexQuery,ConvexMutation,ConvexActionandPaginatedQueryBuilderwhen decoding a successful result fails.ConvexProvider.of(context).functionCaller(extensionConvexRuntimeFunctionCaller) returns a coreConvexFunctionCallerfor the provider's client, so generatedConvexApibindings andConvexStoragecan be built below a provider.ConvexClientRuntimereturns its wrapped client (now also exposed asConvexClientRuntime.client); custom runtime clients can opt in throughConvexFunctionCallerSource.FakeConvexClient: optionalargs:filter onemitSubscription,emitSubscriptionErrorandemitPaginated(emissions stay name-scoped by default);source/hasPendingWritesonemitSubscription;emitSubscriptionLoading;erroronemitPaginated; recordedqueryCalls/mutationCalls/actionCalls(FakeConvexCall, including the mutation'soptimisticUpdate);isDisposed;FakeConvexPaginatedQuery.argsandlastLoadMoreNumItems;FakeConvexSubscription.args; andfunctionCallersupport. The dartdoc lists where the fake intentionally differs from the real client.ConvexImage.errorBuilderandConvexCachedImage.errorBuilder(ConvexImageErrorBuilder) receive the error and aretrycallback. Breaking (behavior): withouterrorBuilderorerrorWidget, load failures are now reported toFlutterError.reportError(likeImage.network) instead of being invisible.ConvexImage.httpClientandConvexFileDownloader.download(client:, abortTrigger:): downloads can use a caller-owned client, and an in-flight download can be aborted.
Changed #
-
Breaking: the unnamed
ConvexAssetCacheconstructor is now a factory: instances with the samecacheKeyshare one ref-countedCacheManager(classes extendingConvexAssetCachemust useConvexAssetCache.custom).ConvexOfflineImagenow reports "no cached asset and no URL" as aConvexStorageExceptioninstead of aString. -
The native-only media helpers (
ConvexImage,ConvexCachedImage,ConvexOfflineImage,ConvexAssetCache,ConvexFileDownloader) are now exported through a conditional export: web (JS and WASM) builds get API-compatible stand-ins that render the error state or fail with anUnsupportedError, so the package's web import graph no longer reachesdart:ioorflutter_cache_manager(WASM-compatible on pub.dev). Native behavior is unchanged. On web,ConvexAssetCache.customtakes anObjectandConvexAssetSnapshot.fileis alwaysnull. -
Breaking (tests):
FakeConvexClientnow behaves like a disposedConvexClientafterdispose():subscribe,paginatedQueryandreconnectNowthrow andquery/mutate/actionreject withConvexException('ConvexClient has been disposed'); emissions are ignored.FakeConvexPaginatedQuery.loadMorereturnstrueonly while the current status iscanLoadMore, like the real engine (it always returnedtrue). -
Breaking: Requires Dart
^3.10.0and Flutter>=3.38.1, and on Apple platforms iOS 15 / macOS 12 or later; apps must raiseIPHONEOS_DEPLOYMENT_TARGET/MACOSX_DEPLOYMENT_TARGET(and their Podfileplatform, if any).cupertino_httpis now>=3.1.0 <4.0.0(up from^2.4.0, which excluded the current major and conflicted with apps already on it),objective_c>=9.5.0 <10.0.0andhttp^1.5.0. On Flutter 3.47 and later pub resolvescupertino_http3.1.1 /objective_c9.6, which carry upstream native memory-leak fixes; earlier Flutter releases pinmetabelow what those versions need and get 3.1.0 / 9.5. (Flutter 3.38.0 itself shipped a prerelease Dart 3.10 build that^3.10.0does not accept.) -
connectivity_plusnow accepts>=6.1.0 <8.0.0, so apps onconnectivity_plus7.x can depend ondartvex_flutter. (7.x itself raises the Android build requirements to AGP 8.12.1, Gradle 8.13 and Kotlin 2.2.) -
The NSURLSession WebSocket transport now runs every connection on one shared, process-wide
URLSessionand sends theConvex-Clientheader on the handshake request. Foundation never fully releases a session that has run a WebSocket task, even after invalidation, so the previous session-per-connection design still leaked a native session on every reconnect. -
Breaking: decode failures are now a public
ConvexDecodeExceptioneverywhere:ConvexQueryused a private wrapper type, andConvexMutation/ConvexActionsurfaced the raw decoder error, indistinguishable from a rejected request even though the server had already committed the write. Code catching the raw decoder error (for exampleon TypeError) from a mutation or action future must catchConvexDecodeExceptioninstead. -
Breaking (behavior):
PaginatedQueryBuilderreports item decode failures toFlutterError.reportError(still contained: noErrorWidget), instead of silently switching to the error status. Widget tests that pump undecodable items now see the reported error. -
ConvexClientRuntimeno longer keeps aconnectionStatelistener (it reads the wrapped client's state directly), and two wrappers around the same client with the samedisposeClientare now equal. A wrapper re-created inline in abuildmethod no longer makes every descendant resubscribe, reset pagination, or re-download images, and no longer leaks a listener per rebuild. -
ConvexProviderno longer callsreconnectNowon app resume for a lazy client (connectImmediately: false) that has not started yet, which opened a socket before the first backend operation or auth update. -
ConvexMutationandConvexActionshare one request state machine; their single-flight behavior (a call made while another is in flight rejects with aStateError) is unchanged and now documented. -
dev_dependencies:flutter_lints^6.0.0. -
README: no longer promises that additions to
ConvexRuntimeClientare non-breaking for custom implementations, and documents the sampleConvexLocalClientadapter in the example app. -
The
ConvexQuerySourcedartdoc now states that, withConvexClientRuntime,sourceonly reflects pending optimistic writes: a subscription seeded from the core's recently-unsubscribed cache is reported asremoteand may be stale until the next server result.
Fixed #
- Download and asset-cache errors no longer leak a malformed signed URL: a
FormatExceptionloses itssource, and other errors mentioning the URL become URL-freeClientExceptions. ConvexAssetCache.prefetch(force: true)downloads the whole file before swapping it in, so a failed refresh keeps the previous copy even when the file type changes (flutter_cache_manager deleted it on the headers).ConvexImagereloads when itshttpClientchanges and aborts the download running on the previous client.ConvexFileDownloader.downloadfails withHttpExceptionWithStatus(anHttpException) on non-2xx responses.- Asset cache errors redact signed URLs, including redirected URLs and HTTP exception messages, before reaching image error builders or crash reporters.
- The Apple HTTP wrapper waits for asynchronous response cancellation before closing the native client, preventing a leaked session after an abort.
ConvexFileDownloadererrors (HttpException,ClientException,RequestAbortedException) carry the URL reduced to its origin. File URLs are bearer capabilities (a storage URL's path, a presigned URL's query), and these errors reachFlutterError.reportErrorand crash reporters throughConvexImage/ConvexCachedImage.ConvexCachedImage: retrying a failed refresh after a client or URL resolver change still bypasses the cache instead of serving the file cached for the previous client, and a superseded download of the same entry can no longer finish after (and overwrite) the newer one.- On iOS and macOS the default HTTP client (used by storage uploads, asset
downloads and auth adapters such as
dartvex_auth_better) kept cookies in the shared, persistentHTTPCookieStorageand attached them to later requests. A Better Auth session cookie stored by sign-in then made sign-out and the next sign-in fail with 403 (missing Origin) and could override the explicit bearer token. Both NSURLSession transports (the default HTTP client installed byinstallCupertinoTransport()and the WebSocket) now use an ephemeral, cookie-less configuration, matching thedart:ioand web transports, which never sent cookies. - HTTP clients created by the default factory on Apple platforms can be
closed while a request is still running (for example from a
finallyafter a timeout);cupertino_http3 would otherwise throw aStateErrorthat masks the original failure. The native session is released once the last request finishes. - The NSURLSession WebSocket close/error state machine is now covered by unit tests through a native-task seam.
ConvexAuthBuilder,ConvexConnectionBuilder,ConvexConnectionStatusBuilderandConvexAuthRefreshingBuilderkept the previous client's last value after the client was swapped (for example a fresh signed-out auth client kept showing the signed-in user). They now re-seed from the new client's current value.ConvexQuerykept the previous client's data (withhasData: true) after a client swap, even next to the new client's error. A client change now resets to the loading state; changing only the query or args on the same client still keeps the previous data while refreshing.- Widgets driven by the core's synchronous streams no longer throw
"setState() called during build" when the client emits during a build or
layout pass — for example
loadMore()called from aListView.itemBuilder, a lazy client connecting because a descendant subscribed, orloginFromCache()from a descendant'sinitState. The rebuild is deferred to after the frame. - Calling the
ConvexMutation/ConvexActionexecutor after the widget was unmounted threw before the request was sent; the request is now sent and only the snapshot update is skipped. ConvexQueryrenders the client's live result in its first frame, instead of a loading frame, when another widget already holds a live subscription to the same query and arguments through aConvexClientRuntimeof the same client.ConvexQueryandPaginatedQueryBuilderno longer throw out of lifecycle methods (replacing the subtree with anErrorWidget) when the client rejects the subscription synchronously, for example a disposed client. They show an error state and retry on the next dependency or client change.PaginatedQueryBuilderonly decodes items whose raw value changed since the previous emission, and no longer copies the item list on every build.- A
FakeConvexClientquery handler that throws now delivers aConvexRuntimeQueryErrorevent (an error snapshot) instead of an uncaught microtask error. Themutatedartdoc no longer suggests observing the optimistic update from a handler, which never received it. ConvexAssetCache(cacheKey: k)instances (includingConvexAssetCache.shared) each opened their ownCacheManagerover the same database and file directory, and disposing one closed the store under the others. They now share one store per key, closed (with its HTTP client) when the last instance is disposed;dispose()is idempotent.ConvexAssetCache.prefetch(force: true)(also used byConvexCachedImageafter a client or resolver change) removed the cached file before downloading, so a failed refresh lost the offline copy. The new file now replaces the old one only after a successful download.ConvexOfflineImageno longer flashes a loading frame (and re-reads the cache) when only itsurlchanges — rotating signed URLs, orurlbecomingnulloffline — while the asset is already shown.ConvexImageaborts the running download when it is disposed or starts a new load, and reuses one HTTP client (one connection pool, one URLSession on Apple platforms) for every image instead of creating one per download.ConvexCachedImagecompares clients with==, so an equal re-createdConvexClientRuntimeno longer bypasses the cache and re-downloads.- The
ConvexImagedartdoconProgressexample printedp * 100; it now usesp.progress. - Disposing a
ConvexAssetCache()right after creating it, or after its metadata store failed to open (for example the SQLite backend used on Android, iOS and macOS when its plugin is unavailable), threw a null-check error fromflutter_cache_manager's repositoryclose(), whichCacheManager.dispose()calls without waiting for the open.dispose()now waits for a pending open and skips closing a store that never opened; a failed open surfaces as an error of each cache operation instead of an uncaught async error. A store re-created for the samecacheKeywhile the previous one is still closing opens only after that close. - A
ConvexMutation/ConvexActionrequest still in flight when the widget was unmounted left the executor "in progress" forever, so every later call through it (allowed after unmount) failed with aStateError. ConvexFileDownloader.download(andConvexImage) now aborts the request when waiting for the response headers or draining an error body times out; it previously stopped waiting but left the request running on the client.- The Apple default HTTP client no longer keeps its native session open
forever when an aborted request's response is never read (a caller that
timed out and moved on): an abort releases the request, and a late reader
gets a
RequestAbortedException.
0.2.0 - 2026-06-12 #
Changed #
- Breaking for implementors (noted after release): classes that
implement ConvexRuntimeClientmust add the members introduced in this release —paginatedQuery,connectionStatus,currentConnectionStatus,authRefreshing,currentAuthRefreshing— and the optionalOptimisticUpdate? optimisticUpdateparameter onmutate. Code that only usesConvexClientRuntimeorFakeConvexClientis unaffected.
Added #
ConvexClientRuntimenow preserves successful query log lines and maps real core optimistic query emissions tosource: cachewithhasPendingWrites: true.- Rich connection status:
ConvexRuntimeClientgainsconnectionStatus(aStream<ConnectionStatus>) andcurrentConnectionStatus, and the newConvexConnectionStatusBuilderrebuilds on the detailed status (inflight counts, retry count, loading,hasEverConnected).ConnectionStatusis re-exported fromdartvex. The coarseConvexConnectionBuilderandConvexConnectionIndicatorare unchanged. PaginatedQueryBuilderis now backed by the core reactive pagination engine: loaded pages update live as their data changes and stay gapless at page boundaries, instead of being one-shot reads. The widget API (query/builder/fromJson/args/pageSize/client) andPaginationStatusare unchanged.ConvexRuntimeClientgainspaginatedQuery(...)returning aConvexRuntimePaginatedQuery, andConvexPaginatedResult/ConvexPaginationStatusare re-exported fromdartvex.ConvexMutation.optimisticUpdateapplies an optimistic update while the mutation is in flight, overlaying query results instantly and rolling back when it completes or fails.ConvexRuntimeClient.mutatenow accepts an optionalOptimisticUpdate, andOptimisticLocalStore/OptimisticUpdate/OptimisticQueryEntryare re-exported fromdartvexfor convenience.ConnectivityPlusSignal, aconnectivity_plus-backedConnectivitySignal. Pass it toConvexClientConfig.connectivitySignalso the client reconnects immediately when the device regains network connectivity.ConvexAuthRefreshingBuilder, a widget that rebuilds with the client's auth-refreshing state (truewhile auth is being recovered after a server rejection).ConvexRuntimeClientnow exposesauthRefreshingandcurrentAuthRefreshing, backed byConvexClient.authRefreshing.ConvexRuntimeQueryLoading, emitted when the core client reports an optimistic query clear/loading state.- NSURLSession-backed network transports on iOS and macOS, installed
automatically at startup via Dart plugin registration
(
DartvexFlutterPlugin.registerWith()). All SDK network paths — the sync WebSocket, storage uploads, auth endpoints, asset-cache downloads, andConvexFileDownloader— now use the same system network path as Safari and native apps instead of rawdart:iosockets. POSIX sockets are discouraged by Apple (they bypass VPNs, proxies, and per-app network policy; see dart-lang/sdk#41376) and are blackholed witherrno 65on some iOS devices. Apps can opt out by resettingdefaultWebSocketAdapterOverrideanddefaultHttpClientFactorytonullearly inmain(), or override per client withConvexClientConfig.adapterFactory/ explicithttpClientparameters as before.installCupertinoTransport()is exported to re-install the defaults after an opt-out. Addscupertino_http,http,objective_c, andweb_socketdependencies; the package is now a Dart-only plugin on iOS/macOS. - The WebSocket transport uses a session-owning NSURLSession socket: the
URLSessioncreated for each connection attempt is invalidated once the connection ends. UpstreamCupertinoWebSocketnever invalidates its session, which leaks a native session per connect — a real cost for a sync client that reconnects indefinitely (dart-lang/http#1282). defaultWebSocketAdapterOverrideanddefaultHttpClientFactoryare re-exported fromdartvex_flutter, so the documented transport opt-out is reachable without a directdartveximport.
Changed #
- Requires
dartvex^0.2.0so web consumers resolve the current JavaScript-compatible value codec. - Requires Dart
^3.8.0and Flutter>=3.32.0, matching the minimums required by the Cupertino transport dependencies. - Clarifies in the README and API docs that disk-backed file/image cache
helpers (
ConvexAssetCache,ConvexCachedImage,ConvexOfflineImage, and progress-download image helpers) are native-only; web apps should render signed storage URLs directly. ConvexQuerynow renders loading when it receives an optimistic clear event, andhasDatarepresents a concrete query result even when that result is Convexnull.PaginatedQueryBuildernow uses the core paginated query's synchronous current snapshot on the first build, so warm remounts can render cached pages without a loading frame.
Fixed #
ConvexQueryandPaginatedQueryBuildernow compare rebuild arguments against the deep-snapshotted args used for the active subscription. Reusing aMapand mutating it in place between parent rebuilds now correctly resubscribes to the new query instead of leaving the widget attached to the previous args.- The NSURLSession WebSocket decodes peer close reasons with
allowMalformed. A close frame carrying invalid UTF-8 previously threw out of the session delegate callback, which skipped the close event entirely — leaving the sync layer blind to the disconnect until its inactivity timeout — and leaked the owned native session. The close reason is diagnostic-only, so replacement characters are harmless. - The NSURLSession WebSocket now turns unexpected receive/send errors into an abnormal close instead of throwing out of the async task callback, ensuring the owned session is invalidated and the sync layer sees a disconnect.
- The NSURLSession WebSocket adapter now converts raw
socket.eventsstream errors into abnormal close events and cleans up the socket best-effort, instead of letting those errors escape the zone before the core reconnect manager can handle them. ConvexProviderno longer lets the disposed-client error escape into the Flutter lifecycle dispatch when the app resumes after an externally owned client (disposeClient: false) was disposed in the background, including when that error is reported by the reconnect future after lifecycle dispatch returns. The best-effortAppResumedreconnect is skipped instead.- Inline closures no longer reset widget state on parent rebuilds:
decode(ConvexQuery,ConvexMutation,ConvexAction),fromJson(PaginatedQueryBuilder), andoptimisticUpdate(ConvexMutation) are treated as render/call-time mappings instead of subscription identity. Previously a parent rebuild that passed a new closure instance resubscribed the query, reset a paginated list back to its first page, or wiped the request snapshot. Changingdecode/fromJsonnow re-decodes the current value (or re-maps the loaded items) in place. ConvexMutation/ConvexActionno longer surface unhandled zone errors when the returned future is ignored (the normal builder pattern), both for the in-flight guard and for request failures already reported through the snapshot. Awaiting callers still receive the same errors.FakeConvexClient.dispose()no longer throws aConcurrentModificationErrorwhen a subscription listener reacts to its done event by canceling a subscription (done events are delivered synchronously while dispose closes the fake's controllers).- The NSURLSession WebSocket adapter decodes binary frames with
allowMalformed, so a peer sending invalid UTF-8 can no longer throw an uncaughtFormatExceptionout of the socket listener. The garbled message fails JSON parsing upstream instead, driving the normalInvalidServerMessagereconnect. ConvexImageandConvexCachedImagenow treat a changed runtime client as a new load identity, preventing stale images from a previous provider/client and avoiding implicit retries when unchanged failed loads rebuild.- Reactive query and paginated-query widgets now ignore late events from canceled subscriptions after inputs change, preventing stale results from overwriting the newest subscription state.
- Raw errors emitted by custom runtime query or paginated-query streams are now mapped into widget error state instead of escaping as unhandled Flutter stream errors.
- Action and mutation builders now ignore stale in-flight completions after their action/mutation or client changes, so old results cannot overwrite the new request state.
FakeConvexClientnow broadcasts duplicate query subscriptions and paginated queries with the same name to every live handle instead of only the latest.FakeConvexClientnow deep-snapshots query, subscription, mutation, and action arguments before invoking handlers, matching the real client behavior and preventing caller-side map mutations from changing deferred fake results.- Closes file-download HTTP clients and rejects non-success responses instead of returning error bodies as image bytes.
ConvexFileDownloader.downloadnow applies a configurableidleTimeout(default 30s) to connecting, awaiting response headers, and the gap between body chunks, so a stalled server fails with aTimeoutExceptioninstead of leavingConvexImageloading forever with an open HTTP client. It is an idle (inter-event) bound, so large downloads that keep progressing are never cut off.- Ignores stale async image/cache loads after widget inputs change.
- Resets paginated queries when query inputs or client instances change.
- Returns failed futures for overlapping action/mutation requests instead of throwing synchronously.
- Preserves structured query error data and server log lines in runtime errors.
- Supports action-based storage URL resolvers in
ConvexImageandConvexCachedImage. - Normalizes malformed storage URL resolver results in
ConvexImageandConvexCachedImagetoConvexStorageException, instead of surfacing raw cast errors for non-string values. - Excludes build artifacts from the package archive.
ConvexAssetCache.dispose()now closes the HTTP client the cache created for its file service (CacheManager.dispose()never does), releasing its platform resources — an NSURLSession on iOS/macOS.ConvexFileDownloader.downloadnow bounds draining a non-2xx error response body byidleTimeout, so a stalled error response fails with the status error instead of hanging the download forever.
0.1.4 - 2026-04-30 #
0.1.3 - 2026-03-22 #
Added #
ConvexRuntimeClient.reconnectNow(String reason)— propagate reconnect to the Flutter runtime layer.- App lifecycle listener in
ConvexProvider— automatically forces a reconnect when the app resumes from background if the connection is not active.
0.1.2 - 2026-03-21 #
Improved #
- Added comprehensive dartdoc comments on all public API
- Added example file for pub.dev scoring
0.1.1 - 2026-03-21 #
0.1.0 - 2026-03-15 #
Added #
- ConvexQuery reactive widget for query subscriptions
- ConvexMutation widget for executing mutations
- ConvexAction widget for action invocation
- ConvexProvider for dependency injection
- ConvexConnectionBuilder and ConvexConnectionIndicator
- ConvexAuthProvider and ConvexAuthBuilder
- ConvexImage widget for displaying storage images
- PaginatedQueryBuilder for cursor-based pagination
- FakeConvexClient test helper for testing
- ConvexOfflineImage with asset caching
- ConvexAssetCache for offline binary asset caching
- Runtime-interface based integration via ConvexClientRuntime
- Widget tests, example app, and package documentation