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/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index b700e1c7..150eeca4 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -99,6 +99,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. /// @@ -113,11 +115,19 @@ class CacheManager implements BaseCacheManager { 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; } @@ -126,6 +136,7 @@ class CacheManager implements BaseCacheManager { String url, String? key, Map? headers, + Duration? timeout, bool withProgress, ) async { key ??= url; @@ -148,6 +159,7 @@ class CacheManager implements BaseCacheManager { url, key: key, authHeaders: headers, + timeout: timeout, )) { if (response is DownloadProgress && withProgress) { streamController.add(response); @@ -184,6 +196,7 @@ class CacheManager implements BaseCacheManager { String url, { String? key, Map? authHeaders, + Duration? timeout, bool force = false, }) async { key ??= url; @@ -192,6 +205,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 c6f3a59d..79a9aa85 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 @@ -31,6 +31,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, 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. /// @@ -44,6 +46,7 @@ abstract class BaseCacheManager { String url, { String? key, Map? headers, + Duration? timeout, bool withProgress, }); @@ -52,6 +55,7 @@ abstract class BaseCacheManager { String url, { String? key, Map? authHeaders, + Duration? timeout, bool force = false, }); 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 5851a7ab..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,10 +17,15 @@ 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, Map? headers, + Duration? timeout, bool withProgress = false, int? maxHeight, int? maxWidth, @@ -30,6 +35,7 @@ mixin ImageCacheManager on BaseCacheManager { url, key: key, headers: headers, + timeout: timeout, withProgress: withProgress, ); return; @@ -50,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, @@ -58,6 +66,7 @@ mixin ImageCacheManager on BaseCacheManager { withProgress, maxWidth: maxWidth, maxHeight: maxHeight, + timeout: timeout, ).asBroadcastStream(); _runningResizes[resizedKey] = runningResize; } @@ -130,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) { 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 7d6fdbc6..8cdbac22 100644 --- a/flutter_cache_manager/lib/src/compat/file_service_compat.dart +++ b/flutter_cache_manager/lib/src/compat/file_service_compat.dart @@ -13,9 +13,13 @@ class FileServiceCompat extends FileService { Future get( String url, { Map? headers, + Duration? timeout, }) async { - final legacyResponse = await fileFetcher(url, headers: headers); - return CompatFileServiceGetResponse(legacyResponse); + 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 376d672e..52059f77 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 @@ -31,14 +35,19 @@ class HttpFileService extends FileService { Future get( String url, { 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 d5b77146..ed629c0d 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -33,6 +33,7 @@ class WebHelper { String url, { String? key, Map? authHeaders, + Duration? timeout, bool ignoreMemCache = false, }) { key ??= url; @@ -40,7 +41,7 @@ class WebHelper { if (subject == null || ignoreMemCache) { subject = BehaviorSubject(); _memCache[key] = subject; - _downloadOrAddToQueue(url, key, authHeaders); + _downloadOrAddToQueue(url, key, authHeaders, timeout); } return subject.stream; } @@ -51,6 +52,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) { @@ -69,6 +71,7 @@ class WebHelper { url, key, authHeaders: authHeaders, + timeout: timeout, )) { subject.add(result); } @@ -78,14 +81,14 @@ 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 @@ -93,6 +96,7 @@ class WebHelper { String url, String key, { Map? authHeaders, + Duration? timeout, }) async* { var cacheObject = await _store.retrieveCacheData(key); cacheObject = cacheObject == null @@ -103,13 +107,14 @@ 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, + Duration? timeout, ) { final headers = {}; @@ -124,7 +129,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/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 diff --git a/flutter_cache_manager/test/mock.mocks.dart b/flutter_cache_manager/test/mock.mocks.dart index a1496764..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,32 +390,41 @@ 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, }) => (super.noSuchMethod( - Invocation.method(#get, [url], {#headers: headers}), - returnValue: _i4.Future<_i3.FileServiceResponse>.value( + Invocation.method( + #get, + [url], + {#headers: headers, #timeout: timeout}, + ), + returnValue: _i3.Future<_i2.FileServiceResponse>.value( _FakeFileServiceResponse_4( this, - Invocation.method(#get, [url], {#headers: headers}), + Invocation.method( + #get, + [url], + {#headers: headers, #timeout: timeout}, + ), ), ), ) - 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( @@ -422,7 +432,7 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { Invocation.getter(#fileFetcher), ), ) - as _i3.FileService); + as _i2.FileService); @override int get concurrentCalls => @@ -436,10 +446,11 @@ 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, + Duration? timeout, bool? ignoreMemCache = false, }) => (super.noSuchMethod( @@ -449,10 +460,11 @@ class MockWebHelper extends _i1.Mock implements _i7.WebHelper { { #key: key, #authHeaders: authHeaders, + #timeout: timeout, #ignoreMemCache: ignoreMemCache, }, ), - returnValue: _i4.Stream<_i3.FileResponse>.empty(), + returnValue: _i3.Stream<_i2.FileResponse>.empty(), ) - as _i4.Stream<_i3.FileResponse>); + as _i3.Stream<_i2.FileResponse>); }