brick_offline_first
A Brick domain that routes data fetching through local providers before remote providers.
4.0.2
7.9K downloads/mo
#3254 most downloaded on pub.dev
GetDutchie/brick
What this package is like to depend on
Last release 9 months ago
01 Nov 2025
Release timing varies
gaps range from 2 weeks to 11 months
Most releases are documented
notes for 25 of 28 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
40 releases · first in 2020
1 release in the last 12 months
see the full history below
Release timeline
40 releases · Jan 2020 to Nov 2025Releases
latest 40-
4.0.201 Nov 2025Release notes
Open source →- Hydrate the memory cache when using destructiveLocalSyncFromRemote (#640)
-
4.0.108 Jul 2025 -
4.0.024 Feb 2025Release notes
Open source →- BREAKING CHANGE Require
brick_core: >= 2.0.0and remove support forQuery(providerArgs:); see migration steps - Dart minimum SDK is updated to
3.4.0 - All dependency restrictions are updated to include the minimum released version.
- BREAKING CHANGE Require
-
3.4.024 Dec 2024Release notes
Open source →- Upgrade
brick_coreto1.3.0 - Update analysis to modern lints
- Change
OfflineFirstRepository#existsbehavior: the check against memory cache will only returntrueif results have been found, otherwise it will continue to the SQLite provider - Forward errors from
OfflineFirstRepository#subscribestreams to their callers (@sonbs21 #484)
- Upgrade
-
3.3.029 Oct 2024Release notes
Open source →- Added
subscriptionByQuerytoOfflineFirstRepository#notifySubscriptionsWithLocalDatato pass a custom map ofStreamControllers - Add
GetFirstMixinfor convenient retrieval of the first results ofOfflineFirstRepository#get - Close all controllers in
OfflineFirstRepository#subscriptionsand clear the map onOfflineFirstRepository#reset
- Added
-
3.2.120 Sep 2024 -
3.2.027 May 2024Release notes
Open source →- Apply desired policy to all association fetches during
OfflineFirstRepository#getrequests. Fixes #371. - Upgrade minimum Dart to 2.18
- Apply desired policy to all association fetches during
-
3.1.010 Jul 2023Release notes
Open source →- Apply standardized lints
- Respect
awaitRemotepolicy forOfflineFirstRepository#get- fixes a bug where an instance in memory cache would early-return before hitting remote despite the requestedawaitoralwaysHydratepolicy
-
3.0.323 May 2023 -
3.0.212 Apr 2023Release notes
Open source →- Permit awaiting remote on first
getinOfflineFirstRepository#subscribe. While the default for thepolicyargument of this method has changed, it was unapplied (.localOnlywas used regardless).
- Permit awaiting remote on first
-
3.0.107 Apr 2023Release notes
Open source →- Resolve concurrent modification error when looping through subscriptions
-
3.0.010 Mar 2023Release notes
Open source →- Remove
brick_sqlite_abstract - Remove
brick_offline_first_abstract - Add
OfflineFirstRepository#subscribe. The query provided when invoked is stored on the repository. Whenever data is locally mutated withstoreRemoteResultsorupsertordeletethat matches one of these stored queries, the stream receives the latest data for the query. It is strongly recommended to store the subscription after creating the stream and listening to it; cancelling the stream will close it and remove the stream to prevent memory leaks. - Add
fieldsToOfflineFirstRuntimeDefinitiontoOfflineFirstAdapter. This exposes@OfflineFirst(whereconfiguration to repositories - Add
applyToRemoteDeserializationto@OfflineFirst. Whentrue(the default and existing behavior), deserializing methods will query based onwhereconfiguration
- Remove
-
3.0.0-pre.522 Feb 2023 pre-releaseNothing published for this version
-
3.0.0-pre.422 Feb 2023 pre-releaseNothing published for this version
-
3.0.0-pre.322 Feb 2023 pre-releaseNothing published for this version
-
3.0.0-pre.213 Feb 2023 pre-releaseNothing published for this version
-
3.0.0-pre.113 Feb 2023 pre-releaseNothing published for this version
-
2.1.203 Nov 2022Release notes
Open source →- Set default of 5 seconds for
RequestSqliteCacheManager#processingInterval
- Set default of 5 seconds for
-
2.1.115 Jun 2022 -
2.1.004 Apr 2022Release notes
Open source →- Loosen dependency restrictions to major versions
- Remove Flutter dependency by upgrading
brick_sqlite
-
2.1.0-rc.121 Feb 2022 pre-releaseNothing published for this version
-
2.0.016 Feb 2022Release notes
Open source →- BREAKING CHANGE
requireRemotehas been removed fromget()andgetBatched(). Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate - BREAKING CHANGE
hydrateUnexistinghas been removed fromget(). Instead, usepolicy: OfflineFirstGetPolicy.awaitRemoteWhenNoneExist(this is the default). - BREAKING CHANGE
alwaysHydratehas been removed fromget(). Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate. - BREAKING CHANGE This package no longer includes the
OfflineFirstWithRestdomain. Please addbrick_offline_first_with_rest: anyto yourpubspec.yamland update package imports appropriately. - Use forked
brick_offline_first_with_PROVIDER_abstractpackages - BREAKING CHANGE
restproperties have been removed fromOfflineFirstException. UseOfflineFirstWithRestExceptioninstead frombrick_offline_first_with_rest. - Add
GraphqlOfflineRequestQueueto support offline caching within theGraphqlProvider - Add
applyPolicyToQuerytoOfflineFirstRepositoryto add the policy before requests are made to remote providers. - Add
OfflineFirstDeletePolicy,OfflineFirstGetPolicy, andOfflineFirstUpsertPolicyto override default behavior deletenow supports requiring a successful remote withOfflineFirstDeletePolicy.requireRemote. If the app is offline, normally handled exceptions (ClientExceptionandSocketException) arerethrown. (#182)upsertnow supports requiring a successful remote withOfflineFirstUpsertPolicy.requireRemote. If the app is offline, normally handled exceptions (ClientExceptionandSocketException) arerethrown.- Rename
RequestSqliteCacheManagertoRestRequestSqliteCacheManager - Rename
OfflineQueueHttpClienttoRestOfflineQueueClient - Rename
OfflineRequestQueuetoRestOfflineRequestQueue
- BREAKING CHANGE
-
2.0.0+116 Feb 2022Nothing published for this version
-
2.0.0-rc.414 Feb 2022 pre-releaseRelease notes
Open source →- Add
applyPolicyToQuerytoOfflineFirstRepositoryto add the policy before requests are made to remote providers.
- Add
-
2.0.0-rc.314 Feb 2022 pre-releaseRelease notes
Open source →- Add
OfflineFirstDeletePolicy,OfflineFirstGetPolicy, andOfflineFirstUpsertPolicyto override default behavior deletenow supports requiring a successful remote withOfflineFirstDeletePolicy.requireRemote. If the app is offline, normally handled exceptions (ClientExceptionandSocketException) arerethrown. (#182)upsertnow supports requiring a successful remote withOfflineFirstUpsertPolicy.requireRemote. If the app is offline, normally handled exceptions (ClientExceptionandSocketException) arerethrown.- BREAKING CHANGE
requireRemotehas been removed fromget()andgetBatched(). Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate - BREAKING CHANGE
hydrateUnexistinghas been removed fromget(). Instead, usepolicy: OfflineFirstGetPolicy.awaitRemoteWhenNoneExist(this is the default). - BREAKING CHANGE
alwaysHydratehas been removed fromget(). Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate.
- Add
-
2.0.0-rc.3+114 Feb 2022 pre-releaseNothing published for this version
-
2.0.0-rc.202 Feb 2022 pre-releaseRelease notes
Open source →- BREAKING CHANGE This package no longer includes the
OfflineFirstWithRestdomain. Please addbrick_offline_first_with_rest: anyto yourpubspec.yamland update package imports appropriately. - Use forked
brick_offline_first_with_PROVIDER_abstractpackages - BREAKING CHANGE
restproperties have been removed fromOfflineFirstException. UseOfflineFirstWithRestExceptioninstead frombrick_offline_first_with_rest.
- BREAKING CHANGE This package no longer includes the
-
2.0.0-rc.131 Jan 2022 pre-releaseRelease notes
Open source →- Add
GraphqlOfflineRequestQueueto support offline caching within theGraphqlProvider - Rename
RequestSqliteCacheManagertoRestRequestSqliteCacheManager - Rename
OfflineQueueHttpClienttoRestOfflineQueueClient - Rename
OfflineRequestQueuetoRestOfflineRequestQueue
- Add
-
1.1.007 Dec 2021Release notes
Open source →- Carry
providerArgsfrom query when usinggetBatched(#200) - Add Flutter Lints
- Carry
-
1.0.011 Aug 2021Release notes
Open source →- Null safety
- Priority for the next job to process from the queue - when processing requests in serial - has changed from
'$HTTP_JOBS_CREATED_AT_COLUMN ASC, $HTTP_JOBS_ATTEMPTS_COLUMN DESC, $HTTP_JOBS_UPDATED_AT ASC'to'$HTTP_JOBS_CREATED_AT_COLUMN ASC'; this uses the job column introduced in 0.0.7 (26 May 2020) and will not affect any implementations using 0.0.7 or higher. RequestSqliteCacheno longer queries cached requests based on headers; requests are rediscovered based on their encoding, URL, request method, and body. Rehydrated (reattempted) requests will be hydrated with headers from the original request.- BREAKING CHANGE Field types in models
Set<Future<OfflineFirstModel>>,List<Future<OfflineFirstModel>>, andFuture<OfflineFirstModel>are no longer supported. Instead, useSet<OfflineFirstModel>,List<OfflineFirstModel>, andOfflineFirstModel(the adapters willawaiteach). - BREAKING CHANGE
StubOfflineFirstWithRestis functionally changed. SQLiteFFI has satisfied much of the original stubbing required for this class, and http's testing.dart library is sufficient to not require Mockito. Therefore,verifycalls will no longer be effective in testing on the client. Instead, passStubOfflineFirstWithRest.clientto yourRestProvider#clientwith the response values.StubOfflineFirstWithRestModelhas been removed. Please review Offline First Testing for implementation examples. - Do not reprocess queue requests during a single attempt. Server response times may be greater than the reattempt timer; in these situations, requests should remain locked.
- Introduce mutex around processing in the
OfflineRequestQueue. This will avoid simultaneous DB writes on different isolates* while a previous operation is still performing.
*Or sub routines? Microtasks? It's unclear how Timer moves its work to the background or how to force it to remain in the original "thread."
-
1.0.0-nullsafety.005 Apr 2021 pre-releaseNothing published for this version
-
0.1.310 May 2021Nothing published for this version
-
0.1.222 Feb 2021Release notes
Open source →- Add
mixins.dartfor non essential but still regularly requested features that depend on a specific format of remote data or are useful variations of existing features.DeleteAllMixinandDestructiveLocalSyncFromRemoteMixinare the first two such mixins. - Expose
RequestSqliteCache#findRequestInDatabasefor subclass methods. (#111)
- Add
-
0.1.016 Jul 2020Release notes
Open source →- BREAKING CHANGE One-to-many and many-to-many SQLite associations are no longer stored as JSON-encoded strings (i.e.
[1, 2, 3]in a varchar column). Join tables are now generated by Brick. To convert existing data, please refer to the brick_sqlite CHANGELOG notes. If you do not care about existing migration and have not widely distributed your app, simply delete all existing migrations, delete all existing app installs, and runflutter pub run build_runner buildin your project root. - Fixes undefined method when calling
hydrateoffline. The remote provider would return null, and SQLite/memory cache would not adequately store results. Instead, when a null response is returned from the remote provider, subsequent provider updates are skipped. - Adds a configurable option to throw on status codes that are normally swallowed in
OfflineFirstWithRest#upsert(such as 404, 50x).
- BREAKING CHANGE One-to-many and many-to-many SQLite associations are no longer stored as JSON-encoded strings (i.e.
-
0.0.726 May 2020Release notes
Open source →- Add
reattemptForStatusCodeforOfflineFirstWithRestRepository#upsertrequests. When the response matches a reattempt code, an exception is not thrown and the instance is returned instead. - Add
501toOfflineQueueHttpClient#reattemptForStatusCodedefaults - Insert a
created_atcolumn for the OfflineRequestQueue. - Fix a bug where an HTTP request would be immediately duplicated. In some race conditions, the interval timer would immediately recreate the request after it was inserted and before the HTTP response was received.
- Bump sqflite to 1.3.0
- BREAKING CHANGE Remove StubSqlite from StubOfflineFirst. SQLite should be migrated by the repository and data upserted as it would be within the app.
StubOfflineFirstis now only concerned with REST responses. - BREAKING CHANGE Remove interval from
OfflineRequestQueuein favor of declaring it once onRequestSqliteCacheManager. To migrate, pass a customRequestSqliteCacheManagerwith the interval time to theOfflineFirstWithRestRepositoryconstructor. - BREAKING CHANGE
StubOfflineFirstWithRestmust be invoked synchronously (in order to run migrations). When setting up stub in testing, callawait StubOfflineFirstWithRest(...).initialize()or, in a cleaner syntax,final stub = StubOfflineFirstWithRest(...); await stub.initialize().initializewill no longer be automatically invoked.
- Add
-
0.0.603 Mar 2020Release notes
Open source →- Remove maximumRequests configuration for the OfflineFirstQueue. One request should be processed at a time in serial
- Optionally ignore Tunnel not found requests (these occur when connectivity exists but the queried endpoint is unreachable) when making repository requests
- Adds argument to repository to reattempt requests based on the status code from the response
OfflineRequestQueue#processbecame a protected method- Added
RequestSqliteCacheManagerto interact with the queue. This new class receives most static methods fromRequestSqliteCache. - Added
OfflineRequestQueue#requestManagerto access queue via aRequestSqliteCacheManagerinstance. - Renamed
RequestSqliteCache.unprocessedRequeststoRequestSqliteCacheManager.prepareNextRequestToProcessas the expected query only returns one locked row at a time. RequestSqliteCacheManager.prepareNextRequestToProcesslocks all unprocessed rows, not just the first one- Add ability to toggle
serialProcessingforOfflineRequestQueue - Private member
OfflineFirstWithRestRepository#offlineRequestQueueis now protected - Remove
isConnectedmember fromOfflineFirstRepositoryand associated Connectivity code. The connection should not matter to the subclass as it, or a supporting class, should track outbound requests.
-
0.0.524 Jan 2020Release notes
Open source →- Rename
Query#paramstoQuery#providerArgs, reflecting the much narrower purpose of the member
- Rename
-
0.0.5+124 Jan 2020 -
0.0.213 Jan 2020Release notes
Open source →- Export REST annotations/classes from
OfflineFirstWithRestRepositoryfor convenient access - Don't require
MemoryCacheProviderinOfflineFirstWithRestRepositoryas it's not required forOfflineFirstRepository - Fix linter hints
- Export REST annotations/classes from
-
0.0.110 Jan 2020Nothing published for this version