Support for Caching on Web using IndexedDB - #504
Open
ben-milanko wants to merge 24 commits into
Open
Conversation
update, test stub
Open
|
Tested it and it works very well on my app. |
…ync-and-deps # Conflicts: # flutter_cache_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift # flutter_cache_manager/example/pubspec.yaml # flutter_cache_manager/lib/src/config/_config_web.dart # flutter_cache_manager/pubspec.yaml
Raise direct dependency floors to the latest published versions (clock 1.1.3, path_provider 2.1.6, sqflite 2.4.3, build_runner 2.16.1, mockito 5.8.1, web 1.1.1) and record the fork's IndexedDB web support alongside the upstream sync in the changelog. Also picks up the analyzer excludes the Flutter 3.47 toolchain writes into analysis_options.yaml on pub get. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCmKSRuHNETmfGu2TffVzo
Upstream CI now runs `dart format --set-exit-if-changed .`, and the fork's IndexedDB repository, connection pool, file system and example were still in the pre-3.7 style. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCmKSRuHNETmfGu2TffVzo
CI pinned Flutter 3.44.4 while the packages now build against 3.47.1. Raising the pin surfaces two use_super_parameters findings in upstream code, so convert both constructors to super parameters and drop the web_helper import that becomes redundant as a result. `flutter analyze` is clean for both packages on 3.47.1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCmKSRuHNETmfGu2TffVzo
- Introduced `CancellationToken` class to manage request cancellations. - Updated `CacheManager`, `BaseCacheManager`, and `FileService` interfaces to accept `CancellationToken`. - Enhanced file fetching methods to throw `CancelledException` when requests are cancelled. - Added tests for cancellation functionality in `HttpFileService` and `CancellationToken` behavior.
- Updated `ImageCacheManager` methods to accept `CancellationToken` for file fetching operations. - Ensured cancellation support is integrated into both direct file retrieval and resized image handling.
- Changed the constructor to ensure a default http.Client is used if none is provided. - Updated request handling to utilize AbortableRequest for better cancellation support. - Modified tests to reflect the new behavior, ensuring that cancellation after response completion does not throw an exception.
- Added checks to prevent operations on already cancelled requests in `CancellationToken`. - Enhanced `WebHelper` to handle cancellation before starting downloads and during queue processing. - Ensured proper cleanup of subjects associated with cancelled requests to prevent memory leaks.
- Added multiple cancellation checks throughout the file update process in `WebHelper`. - Ensured that cancellation is checked before and after asynchronous operations, including downloads and file saves. - Updated `_manageResponse` and `_saveFile` methods to accept `CancellationToken` for improved cancellation support.
Rebuilds test/mock.mocks.dart against mockito 5.8.1 and applies dart format to the cancellation changes so CI's format check passes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCmKSRuHNETmfGu2TffVzo
…am-sync-and-deps Sync with Baseflow upstream and upgrade dependencies
flutter_cache_manager_firebase depends on flutter_cache_manager ^3.4.2 from pub.dev, which has no CancellationToken. FirebaseHttpFileService overrides HttpFileService.get, so once that signature gained a cancellationToken parameter the package stopped analyzing: error - Undefined class 'CancellationToken' error - The named parameter 'cancellationToken' isn't defined Override the dependency with the sibling package in this repository, so the two move together. Overrides are ignored by consumers, so this does not affect anyone depending on the published package. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TCmKSRuHNETmfGu2TffVzo
…-request-cancellation-2 Network request cancellation (rebased onto the upstream sync)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)
Feature
Flutter web has no persistent caching. Cache is stored only in memory and lost on page refresh.
🆕 What is the new behavior (if this is a feature change)?
Cache metadata and files stored in IndexedDB. Data persists across page refreshes and browser sessions.
💥 Does this PR introduce a breaking change?
No - Non-breaking change. Works automatically without code changes. SDK 3.6.0+ now required.
🐛 Recommendations for testing
📝 Links to relevant issues/docs
#480
#339
#361
#122
🤔 Checklist before submitting