flutter_cache_bloc 0.4.0
flutter_cache_bloc: ^0.4.0 copied to clipboard
Cache-first Bloc primitives with optional persistence for keyed entities, paginated collections, and synchronized multi-list UI.
0.4.0 #
- Adds
HiveCachePersistenceStorage, the recommended default durable storage backed by Hive. - Enables encryption by default for Hive-backed cache snapshots.
- Stores the generated Hive AES key with platform secure storage when no custom encryption key provider is supplied.
- Adds
encrypted: falsefor public/debug caches that intentionally do not need encryption. - Adds
namespace,boxName,path,pathProvider, and customencryptionKeyProviderconfiguration for apps that need finer storage control. - Adds
MemoryCachePersistenceStoragefor tests, examples, previews, and memory-only demonstrations. - Extends
CachePersistenceStoragewithclear()so a storage namespace can be fully reset. - Adds
clearPersistedStorage()toEntityCacheBlocandPagedCacheBlocfor namespace-level durable cleanup. - Updates Bloc close behavior so a manually deleted durable snapshot is not rewritten on close unless a new state change schedules another write.
- Expands code comments and README examples for encrypted persistence, custom storage adapters, cleanup, and retry/outbox use cases.
Breaking changes #
- Custom
CachePersistenceStorageimplementations must now implementclear().
0.3.1 #
- Allows
PagedCacheBloc.insertItemto create a missing collection before inserting the item. This supports durable chat/outbox flows where a delivered message may arrive before that conversation history has been opened in the UI.
0.3.0 #
- Removes the hard dependency on
infinite_scroll_pagination. - Replaces the external
PagingStatein the public API with the package-ownedPagedCacheData, containing pages, keys, flat items, loading, error,hasNextPage, andupdatedAt. - Keeps
PagedCacheViewindependent from any scrolling package so consumers can use Flutter lists,infinite_scroll_pagination, or another UI adapter. - Adds optional durable caching through
CachePersistenceStorage,CacheCodec,EntityCachePersistence, andPagedCachePersistence. - Adds per-key
shouldPersistfilters so one Bloc can keep selected entities or collections durable while leaving the rest memory-only. - Adds optional
maxAgefiltering for restored snapshots. - Adds automatic cache restoration with optional stale-while-revalidate through
refreshAfterRestore. - Queues base and feature-specific Bloc events until restoration completes to prevent startup requests from overwriting durable data.
- Adds
restoredandisRestoredAPIs for startup reconciliation and outbox retry workflows. - Adds debounced writes,
persistNow(),clearPersistedCache(), and durable cleanup whenclearCache()is used. - Adds
clearCacheAndWait()for safe logout and account-switch cleanup before Bloc disposal. - Adds
removeCollection()andclearCache()toPagedCacheBloc. - Keeps restored paged data visible when a background refresh fails.
- Adds persistence, selective-storage, optimistic-item restoration, offline refresh, and memory-only tests.
Breaking changes #
PagedCacheView.builder,PagedCacheBloc.paging,cachedEntries, andPagedCacheState.cachenow exposePagedCacheData<T>instead ofPagingState<int, T>.- Consumers of
infinite_scroll_paginationmust mapPagedCacheDatato that package'sPagingStatein their app or integration layer. PagedCacheData.items,pages, andkeysare non-null collections.
0.2.0 #
- Adds configurable pagination strategies for
PagedCacheBloc. - Adds
PagedCacheBloc.offset(...)forskip + limitAPIs. - Adds
PagedCacheBloc.page(...)for page-number APIs with configurable zero-based or one-based first page. - Adds
PagedCacheBloc.custom(...),PagedCachePageRequest, andCustomPagedCachePaginationfor non-standard integer-key pagination. - Keeps the unnamed
PagedCacheBloc(...)constructor as a backwards-compatible alias for offset pagination. - Updates paged cache rebalancing so generated
PagingState.keysfollow the selected pagination strategy after local insert/update/remove mutations. - Adds tests for offset pagination, zero-based page pagination, and one-based page pagination.
0.1.0 #
- Initial public release.
- Adds
EntityCacheBlocfor cache-first single-entity state keyed by id. - Adds
EntityCacheStateandEntityStatewith loading, refreshing, success, error, TTL, invalidation and read helper APIs. - Adds
PagedCacheBlocfor cache-first paginated lists keyed by id. - Adds LRU-style cache eviction for both entity and paged stores.
- Adds request deduplication to avoid duplicate fetches for the same key.
- Adds stale-while-revalidate behavior for entity cache reads.
- Adds optimistic entity mutations through
upsertEntity,upsertEntityAsandupdateEntity. - Adds paged list mutations through
insertItem,updateItem,removeItemand their cascade/everywhere variants. - Adds
updateFirstItemEverywhereto patch one matching item across every cached paginated list owned by the same Bloc instance. This is useful for social feeds, notifications, marketplace lists and other screens where the same entity appears in multiple tabs or lists. - Adds
refreshCachedWhere,refreshAllCached,refreshActiveand wait helpers for imperative workflows. - Adds
EntityCacheViewandPagedCacheViewwidgets for scopedBlocSelectorrebuilds. - Adds safe handling for unexpected paged fetcher exceptions by storing the
thrown object in the affected
PagingState. - Adds tests covering entity updates, paged loading, paged fetcher exceptions and multi-list synchronization.