From a9312c3421351ae02a6d62a214cc95b50078623a Mon Sep 17 00:00:00 2001 From: "Yu Squire[ Yu, Tsung-Ying ]" Date: Wed, 19 Feb 2025 11:40:08 +0800 Subject: [PATCH 1/6] feat: add `timeout` parameter for downloading --- .../lib/src/cache_manager.dart | 17 ++++++++++--- .../cache_managers/base_cache_manager.dart | 11 ++++++-- .../cache_managers/image_cache_manager.dart | 10 ++++++-- .../lib/src/compat/file_service_compat.dart | 9 ++++--- .../lib/src/web/file_service.dart | 16 +++++++++--- .../lib/src/web/web_helper.dart | 25 +++++++++++-------- flutter_cache_manager/test/mock.mocks.dart | 13 ++++++++-- 7 files changed, 74 insertions(+), 27 deletions(-) diff --git a/flutter_cache_manager/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index 82ac52a9..a8c8a9ba 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -108,11 +108,17 @@ class CacheManager implements BaseCacheManager { /// returned from the cache there will be no progress given, although the file /// might be outdated and a new file is being downloaded in the background. @override - Stream getFileStream(String url, - {String? key, Map? headers, bool withProgress = false}) { + Stream getFileStream( + String url, { + String? key, + Map? headers, + Duration? timeout, + bool withProgress = false, + }) { key ??= url; final streamController = StreamController(); - _pushFileToStream(streamController, url, key, headers, withProgress); + _pushFileToStream( + streamController, url, key, headers, timeout, withProgress); return streamController.stream; } @@ -121,6 +127,7 @@ class CacheManager implements BaseCacheManager { String url, String? key, Map? headers, + Duration? timeout, bool withProgress, ) async { key ??= url; @@ -139,7 +146,7 @@ class CacheManager implements BaseCacheManager { if (cacheFile == null || cacheFile.validTill.isBefore(DateTime.now())) { try { await for (final response - in _webHelper.downloadFile(url, key: key, authHeaders: headers)) { + in _webHelper.downloadFile(url, key: key, authHeaders: headers, timeout: timeout)) { if (response is DownloadProgress && withProgress) { streamController.add(response); } @@ -173,6 +180,7 @@ class CacheManager implements BaseCacheManager { Future downloadFile(String url, {String? key, Map? authHeaders, + Duration? timeout, bool force = false}) async { key ??= url; final fileResponse = await _webHelper @@ -180,6 +188,7 @@ class CacheManager implements BaseCacheManager { url, key: key, authHeaders: authHeaders, + timeout: timeout, ignoreMemCache: force, ) .firstWhere((r) => r is FileInfo); diff --git a/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart index 7449a1bc..8b06ad52 100644 --- a/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart @@ -28,6 +28,7 @@ abstract class BaseCacheManager { /// Get the file from the cache and/or online, depending on availability and age. /// Downloaded form [url], [headers] can be used for example for authentication. + /// [timeout] can be used to specify a timeout for the download. /// The files are returned as stream. First the cached file if available, when the /// cached file is too old the newly downloaded file is returned afterwards. /// @@ -38,11 +39,17 @@ abstract class BaseCacheManager { /// returned from the cache there will be no progress given, although the file /// might be outdated and a new file is being downloaded in the background. Stream getFileStream(String url, - {String? key, Map? headers, bool withProgress}); + {String? key, + Map? headers, + Duration? timeout, + bool withProgress}); ///Download the file and add to cache Future downloadFile(String url, - {String? key, Map? authHeaders, bool force = false}); + {String? key, + Map? authHeaders, + Duration? timeout, + bool force = false}); /// Get the file from the cache. /// Specify [ignoreMemCache] to force a re-read from the database diff --git a/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart index 614d7d9d..69977036 100644 --- a/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart @@ -21,13 +21,19 @@ mixin ImageCacheManager on BaseCacheManager { String url, { String? key, Map? headers, + Duration? timeout, bool withProgress = false, int? maxHeight, int? maxWidth, }) async* { if (maxHeight == null && maxWidth == null) { - yield* getFileStream(url, - key: key, headers: headers, withProgress: withProgress); + yield* getFileStream( + url, + key: key, + headers: headers, + timeout: timeout, + withProgress: withProgress, + ); return; } key ??= url; diff --git a/flutter_cache_manager/lib/src/compat/file_service_compat.dart b/flutter_cache_manager/lib/src/compat/file_service_compat.dart index 0df201e1..c92627f4 100644 --- a/flutter_cache_manager/lib/src/compat/file_service_compat.dart +++ b/flutter_cache_manager/lib/src/compat/file_service_compat.dart @@ -11,9 +11,12 @@ class FileServiceCompat extends FileService { @override Future get(String url, - {Map? headers}) async { - final legacyResponse = await fileFetcher(url, headers: headers); - return CompatFileServiceGetResponse(legacyResponse); + {Map? headers, Duration? timeout}) async { + var legacyResponse = fileFetcher(url, headers: headers); + if (timeout != null) { + legacyResponse = legacyResponse.timeout(timeout); + } + return CompatFileServiceGetResponse(await legacyResponse); } } diff --git a/flutter_cache_manager/lib/src/web/file_service.dart b/flutter_cache_manager/lib/src/web/file_service.dart index 2dcd01d6..b8185945 100644 --- a/flutter_cache_manager/lib/src/web/file_service.dart +++ b/flutter_cache_manager/lib/src/web/file_service.dart @@ -16,7 +16,11 @@ import 'package:http/http.dart' as http; abstract class FileService { int concurrentFetches = 10; - Future get(String url, {Map? headers}); + Future get( + String url, { + Map? headers, + Duration? timeout, + }); } /// [HttpFileService] is the most common file service and the default for @@ -29,14 +33,18 @@ class HttpFileService extends FileService { @override Future get(String url, - {Map? headers}) async { + {Map? headers, Duration? timeout}) async { final req = http.Request('GET', Uri.parse(url)); if (headers != null) { req.headers.addAll(headers); } - final httpResponse = await _httpClient.send(req); - return HttpGetResponse(httpResponse); + var streamedResponse = _httpClient.send(req); + if (timeout != null) { + streamedResponse = streamedResponse.timeout(timeout); + } + + return HttpGetResponse(await streamedResponse); } } diff --git a/flutter_cache_manager/lib/src/web/web_helper.dart b/flutter_cache_manager/lib/src/web/web_helper.dart index 20685484..97db0b1a 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -32,13 +32,14 @@ class WebHelper { Stream downloadFile(String url, {String? key, Map? authHeaders, + Duration? timeout, bool ignoreMemCache = false}) { key ??= url; var subject = _memCache[key]; if (subject == null || ignoreMemCache) { subject = BehaviorSubject(); _memCache[key] = subject; - _downloadOrAddToQueue(url, key, authHeaders); + _downloadOrAddToQueue(url, key, authHeaders, timeout); } return subject.stream; } @@ -49,6 +50,7 @@ class WebHelper { String url, String key, Map? authHeaders, + Duration? timeout, ) async { //Add to queue if there are too many calls. if (concurrentCalls >= fileFetcher.concurrentFetches) { @@ -61,8 +63,8 @@ class WebHelper { concurrentCalls++; final subject = _memCache[key]!; try { - await for (final result - in _updateFile(url, key, authHeaders: authHeaders)) { + await for (final result in _updateFile(url, key, + authHeaders: authHeaders, timeout: timeout)) { subject.add(result); } } on Object catch (e, stackTrace) { @@ -71,19 +73,19 @@ class WebHelper { concurrentCalls--; await subject.close(); _memCache.remove(key); - _checkQueue(); + _checkQueue(timeout); } } - void _checkQueue() { + void _checkQueue(Duration? timeout) { if (_queue.isEmpty) return; final next = _queue.removeFirst(); - _downloadOrAddToQueue(next.url, next.key, next.headers); + _downloadOrAddToQueue(next.url, next.key, next.headers, timeout); } ///Download the file from the url Stream _updateFile(String url, String key, - {Map? authHeaders}) async* { + {Map? authHeaders, Duration? timeout}) async* { var cacheObject = await _store.retrieveCacheData(key); cacheObject = cacheObject == null ? CacheObject( @@ -93,12 +95,15 @@ class WebHelper { relativePath: '${const Uuid().v1()}.file', ) : cacheObject.copyWith(url: url); - final response = await _download(cacheObject, authHeaders); + final response = await _download(cacheObject, authHeaders, timeout); yield* _manageResponse(cacheObject, response); } Future _download( - CacheObject cacheObject, Map? authHeaders) { + CacheObject cacheObject, + Map? authHeaders, + Duration? timeout, + ) { final headers = {}; final etag = cacheObject.eTag; @@ -112,7 +117,7 @@ class WebHelper { headers.addAll(authHeaders); } - return fileFetcher.get(cacheObject.url, headers: headers); + return fileFetcher.get(cacheObject.url, headers: headers, timeout: timeout); } Stream _manageResponse( diff --git a/flutter_cache_manager/test/mock.mocks.dart b/flutter_cache_manager/test/mock.mocks.dart index 708ee9dd..e618131f 100644 --- a/flutter_cache_manager/test/mock.mocks.dart +++ b/flutter_cache_manager/test/mock.mocks.dart @@ -443,12 +443,16 @@ class MockFileServiceBase extends _i1.Mock implements _i3.FileService { _i4.Future<_i3.FileServiceResponse> get( String? url, { Map? headers, + Duration? timeout, }) => (super.noSuchMethod( Invocation.method( #get, [url], - {#headers: headers}, + { + #headers: headers, + #timeout: timeout, + }, ), returnValue: _i4.Future<_i3.FileServiceResponse>.value( _FakeFileServiceResponse_4( @@ -456,7 +460,10 @@ class MockFileServiceBase extends _i1.Mock implements _i3.FileService { Invocation.method( #get, [url], - {#headers: headers}, + { + #headers: headers, + #timeout: timeout, + }, ), )), ) as _i4.Future<_i3.FileServiceResponse>); @@ -499,6 +506,7 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { String? url, { String? key, Map? authHeaders, + Duration? timeout, bool? ignoreMemCache = false, }) => (super.noSuchMethod( @@ -508,6 +516,7 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { { #key: key, #authHeaders: authHeaders, + #timeout: timeout, #ignoreMemCache: ignoreMemCache, }, ), From 188c6a5a2c5e478aaef8842b0c56b4e61c3aeb37 Mon Sep 17 00:00:00 2001 From: "Yu Squire[ Yu, Tsung-Ying ]" Date: Wed, 19 Feb 2025 12:03:48 +0800 Subject: [PATCH 2/6] docs: update comment for `timeout` field --- flutter_cache_manager/lib/src/cache_manager.dart | 2 ++ .../lib/src/cache_managers/base_cache_manager.dart | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/flutter_cache_manager/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index a8c8a9ba..86625774 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -98,6 +98,8 @@ class CacheManager implements BaseCacheManager { /// Get the file from the cache and/or online, depending on availability and age. /// Downloaded form [url], [headers] can be used for example for authentication. + /// [timeout] can be used to specify a timeout for the download, and it will throw + /// a [TimeoutException] when the download takes longer than the specified timeout. /// The files are returned as stream. First the cached file if available, when the /// cached file is too old the newly downloaded file is returned afterwards. /// diff --git a/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart index 8b06ad52..02b95238 100644 --- a/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart @@ -28,7 +28,8 @@ abstract class BaseCacheManager { /// Get the file from the cache and/or online, depending on availability and age. /// Downloaded form [url], [headers] can be used for example for authentication. - /// [timeout] can be used to specify a timeout for the download. + /// [timeout] can be used to specify a timeout for the download, and it will throw + /// a [TimeoutException] when the download takes longer than the specified timeout. /// The files are returned as stream. First the cached file if available, when the /// cached file is too old the newly downloaded file is returned afterwards. /// From 234235a2a17a43541ef3618439957a8e12530b69 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Sat, 3 Oct 2026 02:14:01 +0800 Subject: [PATCH 3/6] fix: apply timeout on the resized image path --- .../lib/src/cache_managers/image_cache_manager.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart index cd6c6f7f..30b9b562 100644 --- a/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart @@ -17,6 +17,10 @@ mixin ImageCacheManager on BaseCacheManager { /// When the resized file is not found in the cache the original is fetched /// from the cache or online and stored in the cache. Then it is resized /// and returned to the caller. + /// + /// [timeout] can be used to specify a timeout for the download, and it will + /// throw a [TimeoutException] when the download takes longer than the + /// specified timeout. Stream getImageFile( String url, { String? key, @@ -52,6 +56,8 @@ mixin ImageCacheManager on BaseCacheManager { } var runningResize = _runningResizes[resizedKey]; if (runningResize == null) { + // Only the first caller for a given [resizedKey] creates this stream; + // concurrent callers share it and therefore inherit its [timeout]. runningResize = _fetchedResizedFile( url, key, @@ -60,6 +66,7 @@ mixin ImageCacheManager on BaseCacheManager { withProgress, maxWidth: maxWidth, maxHeight: maxHeight, + timeout: timeout, ).asBroadcastStream(); _runningResizes[resizedKey] = runningResize; } @@ -132,11 +139,13 @@ mixin ImageCacheManager on BaseCacheManager { bool withProgress, { int? maxWidth, int? maxHeight, + Duration? timeout, }) async* { await for (final response in getFileStream( url, key: originalKey, headers: headers, + timeout: timeout, withProgress: withProgress, )) { if (response is DownloadProgress) { From 96fd4977a28cb1f1e348dcef356beaf57e5e411c Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Sat, 3 Oct 2026 02:15:12 +0800 Subject: [PATCH 4/6] chore: bump to 3.5.0 and add changelog entry --- flutter_cache_manager/CHANGELOG.md | 4 ++++ flutter_cache_manager/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flutter_cache_manager/CHANGELOG.md b/flutter_cache_manager/CHANGELOG.md index 9513fb80..f47c6689 100644 --- a/flutter_cache_manager/CHANGELOG.md +++ b/flutter_cache_manager/CHANGELOG.md @@ -1,3 +1,7 @@ +## [3.5.0] - 2026-10-03 + +* Adds an optional `timeout` parameter to `getFileStream`, `downloadFile`, `getImageFile`, and `FileService.get`, so a download that exceeds it throws a `TimeoutException` instead of running unchecked. + ## [3.4.5] - 2026-09-18 * Prevents image resize decoding from completing more than once and propagates decoding errors ([#400](https://github.com/Baseflow/flutter_cache_manager/issues/400)). diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 3f0c9ce3..49ca35b2 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_cache_manager description: Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. -version: 3.4.5 +version: 3.5.0 homepage: https://github.com/Baseflow/flutter_cache_manager topics: - cache From 016f14fc14f617b9efd79903ff69a30d8db115f4 Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Sat, 3 Oct 2026 02:22:03 +0800 Subject: [PATCH 5/6] test: regenerate mocks with build_runner --- flutter_cache_manager/test/mock.mocks.dart | 189 +++++++++++---------- 1 file changed, 95 insertions(+), 94 deletions(-) diff --git a/flutter_cache_manager/test/mock.mocks.dart b/flutter_cache_manager/test/mock.mocks.dart index 29853801..8462cc9a 100644 --- a/flutter_cache_manager/test/mock.mocks.dart +++ b/flutter_cache_manager/test/mock.mocks.dart @@ -1,16 +1,16 @@ -// Mocks generated by Mockito 5.4.6 from annotations +// Mocks generated by Mockito from annotations // in flutter_cache_manager/test/mock.dart. // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i4; -import 'package:flutter_cache_manager/flutter_cache_manager.dart' as _i3; -import 'package:flutter_cache_manager/src/cache_store.dart' as _i5; -import 'package:flutter_cache_manager/src/storage/cache_object.dart' as _i2; -import 'package:flutter_cache_manager/src/web/web_helper.dart' as _i7; +import 'dart:async' as _i3; + +import 'package:flutter_cache_manager/flutter_cache_manager.dart' as _i2; +import 'package:flutter_cache_manager/src/cache_store.dart' as _i4; +import 'package:flutter_cache_manager/src/web/web_helper.dart' as _i6; import 'package:mockito/mockito.dart' as _i1; -import 'package:mockito/src/dummies.dart' as _i6; +import 'package:mockito/src/dummies.dart' as _i5; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -18,6 +18,7 @@ import 'package:mockito/src/dummies.dart' as _i6; // ignore_for_file: comment_references // ignore_for_file: deprecated_member_use // ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: experimental_member_use // ignore_for_file: implementation_imports // ignore_for_file: invalid_use_of_visible_for_testing_member // ignore_for_file: must_be_immutable @@ -37,7 +38,7 @@ class _FakeDuration_1 extends _i1.SmartFake implements Duration { : super(parent, parentInvocation); } -class _FakeFileSystem_2 extends _i1.SmartFake implements _i3.FileSystem { +class _FakeFileSystem_2 extends _i1.SmartFake implements _i2.FileSystem { _FakeFileSystem_2(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } @@ -48,12 +49,12 @@ class _FakeDateTime_3 extends _i1.SmartFake implements DateTime { } class _FakeFileServiceResponse_4 extends _i1.SmartFake - implements _i3.FileServiceResponse { + implements _i2.FileServiceResponse { _FakeFileServiceResponse_4(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } -class _FakeFileService_5 extends _i1.SmartFake implements _i3.FileService { +class _FakeFileService_5 extends _i1.SmartFake implements _i2.FileService { _FakeFileService_5(Object parent, Invocation parentInvocation) : super(parent, parentInvocation); } @@ -62,37 +63,37 @@ class _FakeFileService_5 extends _i1.SmartFake implements _i3.FileService { /// /// See the documentation for Mockito's code generation for more information. class MockCacheInfoRepositoryBase extends _i1.Mock - implements _i3.CacheInfoRepository { + implements _i2.CacheInfoRepository { MockCacheInfoRepositoryBase() { _i1.throwOnMissingStub(this); } @override - _i4.Future exists() => + _i3.Future exists() => (super.noSuchMethod( Invocation.method(#exists, []), - returnValue: _i4.Future.value(false), + returnValue: _i3.Future.value(false), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future open() => + _i3.Future open() => (super.noSuchMethod( Invocation.method(#open, []), - returnValue: _i4.Future.value(false), + returnValue: _i3.Future.value(false), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future updateOrInsert(_i2.CacheObject? cacheObject) => + _i3.Future updateOrInsert(_i2.CacheObject? cacheObject) => (super.noSuchMethod( Invocation.method(#updateOrInsert, [cacheObject]), - returnValue: _i4.Future.value(), + returnValue: _i3.Future.value(), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future<_i2.CacheObject> insert( + _i3.Future<_i2.CacheObject> insert( _i2.CacheObject? cacheObject, { bool? setTouchedToNow = true, }) => @@ -102,7 +103,7 @@ class MockCacheInfoRepositoryBase extends _i1.Mock [cacheObject], {#setTouchedToNow: setTouchedToNow}, ), - returnValue: _i4.Future<_i2.CacheObject>.value( + returnValue: _i3.Future<_i2.CacheObject>.value( _FakeCacheObject_0( this, Invocation.method( @@ -113,34 +114,34 @@ class MockCacheInfoRepositoryBase extends _i1.Mock ), ), ) - as _i4.Future<_i2.CacheObject>); + as _i3.Future<_i2.CacheObject>); @override - _i4.Future<_i2.CacheObject?> get(String? key) => + _i3.Future<_i2.CacheObject?> get(String? key) => (super.noSuchMethod( Invocation.method(#get, [key]), - returnValue: _i4.Future<_i2.CacheObject?>.value(), + returnValue: _i3.Future<_i2.CacheObject?>.value(), ) - as _i4.Future<_i2.CacheObject?>); + as _i3.Future<_i2.CacheObject?>); @override - _i4.Future delete(int? id) => + _i3.Future delete(int? id) => (super.noSuchMethod( Invocation.method(#delete, [id]), - returnValue: _i4.Future.value(0), + returnValue: _i3.Future.value(0), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future deleteAll(Iterable? ids) => + _i3.Future deleteAll(Iterable? ids) => (super.noSuchMethod( Invocation.method(#deleteAll, [ids]), - returnValue: _i4.Future.value(0), + returnValue: _i3.Future.value(0), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future update( + _i3.Future update( _i2.CacheObject? cacheObject, { bool? setTouchedToNow = true, }) => @@ -150,62 +151,62 @@ class MockCacheInfoRepositoryBase extends _i1.Mock [cacheObject], {#setTouchedToNow: setTouchedToNow}, ), - returnValue: _i4.Future.value(0), + returnValue: _i3.Future.value(0), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future> getAllObjects() => + _i3.Future> getAllObjects() => (super.noSuchMethod( Invocation.method(#getAllObjects, []), - returnValue: _i4.Future>.value( + returnValue: _i3.Future>.value( <_i2.CacheObject>[], ), ) - as _i4.Future>); + as _i3.Future>); @override - _i4.Future> getObjectsOverCapacity(int? capacity) => + _i3.Future> getObjectsOverCapacity(int? capacity) => (super.noSuchMethod( Invocation.method(#getObjectsOverCapacity, [capacity]), - returnValue: _i4.Future>.value( + returnValue: _i3.Future>.value( <_i2.CacheObject>[], ), ) - as _i4.Future>); + as _i3.Future>); @override - _i4.Future> getOldObjects(Duration? maxAge) => + _i3.Future> getOldObjects(Duration? maxAge) => (super.noSuchMethod( Invocation.method(#getOldObjects, [maxAge]), - returnValue: _i4.Future>.value( + returnValue: _i3.Future>.value( <_i2.CacheObject>[], ), ) - as _i4.Future>); + as _i3.Future>); @override - _i4.Future close() => + _i3.Future close() => (super.noSuchMethod( Invocation.method(#close, []), - returnValue: _i4.Future.value(false), + returnValue: _i3.Future.value(false), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future deleteDataFile() => + _i3.Future deleteDataFile() => (super.noSuchMethod( Invocation.method(#deleteDataFile, []), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), ) - as _i4.Future); + as _i3.Future); } /// A class which mocks [CacheStore]. /// /// See the documentation for Mockito's code generation for more information. -class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { +class MockCacheStoreBase extends _i1.Mock implements _i4.CacheStore { MockCacheStoreBase() { _i1.throwOnMissingStub(this); } @@ -222,7 +223,7 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { as Duration); @override - _i3.FileSystem get fileSystem => + _i2.FileSystem get fileSystem => (super.noSuchMethod( Invocation.getter(#fileSystem), returnValue: _FakeFileSystem_2( @@ -230,13 +231,13 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { Invocation.getter(#fileSystem), ), ) - as _i3.FileSystem); + as _i2.FileSystem); @override String get storeKey => (super.noSuchMethod( Invocation.getter(#storeKey), - returnValue: _i6.dummyValue( + returnValue: _i5.dummyValue( this, Invocation.getter(#storeKey), ), @@ -261,7 +262,7 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { ); @override - set fileSystem(_i3.FileSystem? value) => super.noSuchMethod( + set fileSystem(_i2.FileSystem? value) => super.noSuchMethod( Invocation.setter(#fileSystem, value), returnValueForMissingStub: null, ); @@ -273,7 +274,7 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { ); @override - _i4.Future<_i3.FileInfo?> getFile( + _i3.Future<_i2.FileInfo?> getFile( String? key, { bool? ignoreMemCache = false, }) => @@ -283,21 +284,21 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { [key], {#ignoreMemCache: ignoreMemCache}, ), - returnValue: _i4.Future<_i3.FileInfo?>.value(), + returnValue: _i3.Future<_i2.FileInfo?>.value(), ) - as _i4.Future<_i3.FileInfo?>); + as _i3.Future<_i2.FileInfo?>); @override - _i4.Future putFile(_i2.CacheObject? cacheObject) => + _i3.Future putFile(_i2.CacheObject? cacheObject) => (super.noSuchMethod( Invocation.method(#putFile, [cacheObject]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future<_i2.CacheObject?> retrieveCacheData( + _i3.Future<_i2.CacheObject?> retrieveCacheData( String? key, { bool? ignoreMemCache = false, }) => @@ -307,26 +308,26 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { [key], {#ignoreMemCache: ignoreMemCache}, ), - returnValue: _i4.Future<_i2.CacheObject?>.value(), + returnValue: _i3.Future<_i2.CacheObject?>.value(), ) - as _i4.Future<_i2.CacheObject?>); + as _i3.Future<_i2.CacheObject?>); @override - _i4.Future<_i3.FileInfo?> getFileFromMemory(String? key) => + _i3.Future<_i2.FileInfo?> getFileFromMemory(String? key) => (super.noSuchMethod( Invocation.method(#getFileFromMemory, [key]), - returnValue: _i4.Future<_i3.FileInfo?>.value(), + returnValue: _i3.Future<_i2.FileInfo?>.value(), ) - as _i4.Future<_i3.FileInfo?>); + as _i3.Future<_i2.FileInfo?>); @override - _i4.Future emptyCache() => + _i3.Future emptyCache() => (super.noSuchMethod( Invocation.method(#emptyCache, []), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), ) - as _i4.Future); + as _i3.Future); @override void emptyMemoryCache() => super.noSuchMethod( @@ -335,13 +336,13 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { ); @override - _i4.Future removeCachedFile(_i2.CacheObject? cacheObject) => + _i3.Future removeCachedFile(_i2.CacheObject? cacheObject) => (super.noSuchMethod( Invocation.method(#removeCachedFile, [cacheObject]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), ) - as _i4.Future); + as _i3.Future); @override bool memoryCacheContainsKey(String? key) => @@ -352,27 +353,27 @@ class MockCacheStoreBase extends _i1.Mock implements _i5.CacheStore { as bool); @override - _i4.Future dispose() => + _i3.Future dispose() => (super.noSuchMethod( Invocation.method(#dispose, []), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), ) - as _i4.Future); + as _i3.Future); @override - _i4.Future getCacheSize() => + _i3.Future getCacheSize() => (super.noSuchMethod( Invocation.method(#getCacheSize, []), - returnValue: _i4.Future.value(0), + returnValue: _i3.Future.value(0), ) - as _i4.Future); + as _i3.Future); } /// A class which mocks [FileService]. /// /// See the documentation for Mockito's code generation for more information. -class MockFileServiceBase extends _i1.Mock implements _i3.FileService { +class MockFileServiceBase extends _i1.Mock implements _i2.FileService { MockFileServiceBase() { _i1.throwOnMissingStub(this); } @@ -389,7 +390,7 @@ class MockFileServiceBase extends _i1.Mock implements _i3.FileService { ); @override - _i4.Future<_i3.FileServiceResponse> get( + _i3.Future<_i2.FileServiceResponse> get( String? url, { Map? headers, Duration? timeout, @@ -400,7 +401,7 @@ class MockFileServiceBase extends _i1.Mock implements _i3.FileService { [url], {#headers: headers, #timeout: timeout}, ), - returnValue: _i4.Future<_i3.FileServiceResponse>.value( + returnValue: _i3.Future<_i2.FileServiceResponse>.value( _FakeFileServiceResponse_4( this, Invocation.method( @@ -411,19 +412,19 @@ class MockFileServiceBase extends _i1.Mock implements _i3.FileService { ), ), ) - as _i4.Future<_i3.FileServiceResponse>); + as _i3.Future<_i2.FileServiceResponse>); } /// A class which mocks [WebHelper]. /// /// See the documentation for Mockito's code generation for more information. -class MockWebHelper extends _i1.Mock implements _i7.WebHelper { +class MockWebHelper extends _i1.Mock implements _i6.WebHelper { MockWebHelper() { _i1.throwOnMissingStub(this); } @override - _i3.FileService get fileFetcher => + _i2.FileService get fileFetcher => (super.noSuchMethod( Invocation.getter(#fileFetcher), returnValue: _FakeFileService_5( @@ -431,7 +432,7 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { Invocation.getter(#fileFetcher), ), ) - as _i3.FileService); + as _i2.FileService); @override int get concurrentCalls => @@ -445,7 +446,7 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { ); @override - _i4.Stream<_i3.FileResponse> downloadFile( + _i3.Stream<_i2.FileResponse> downloadFile( String? url, { String? key, Map? authHeaders, @@ -463,7 +464,7 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { #ignoreMemCache: ignoreMemCache, }, ), - returnValue: _i4.Stream<_i3.FileResponse>.empty(), + returnValue: _i3.Stream<_i2.FileResponse>.empty(), ) - as _i4.Stream<_i3.FileResponse>); + as _i3.Stream<_i2.FileResponse>); } From 6b6c26b1d6b94c67da25755dd56679961d74ad1b Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Sat, 3 Oct 2026 02:28:07 +0800 Subject: [PATCH 6/6] chore: remove unrelated change --- flutter_cache_manager/analysis_options.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/flutter_cache_manager/analysis_options.yaml b/flutter_cache_manager/analysis_options.yaml index 801d885f..f9b30346 100644 --- a/flutter_cache_manager/analysis_options.yaml +++ b/flutter_cache_manager/analysis_options.yaml @@ -1,4 +1 @@ -analyzer: - exclude: - - build/** include: package:flutter_lints/flutter.yaml