Skip to content

Commit 6354c60

Browse files
authored
Merge branch 'develop' into fix/retrieve-cache-data-exception-handling
2 parents c303009 + 54904e4 commit 6354c60

File tree

6 files changed

+30
-118
lines changed

6 files changed

+30
-118
lines changed

README.md

Lines changed: 0 additions & 106 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flutter_cache_manager/README.md

flutter_cache_manager/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ The more basic usage is explained here. See the complete docs for more info.
2121
The cache manager can be used to get a file on various ways
2222
The easiest way to get a single file is call `.getSingleFile`.
2323

24-
```
25-
var file = await DefaultCacheManager().getSingleFile(url);
24+
```dart
25+
var file = await DefaultCacheManager().getSingleFile(url);
2626
```
2727
`getFileStream(url)` returns a stream with the first result being the cached file and later optionally the downloaded file.
2828

@@ -43,7 +43,7 @@ The easiest way to get a single file is call `.getSingleFile`.
4343
If you use the ImageCacheManager mixin on the CacheManager (which is already done on the DefaultCacheManager) you
4444
get the following `getImageFile` method for free:
4545

46-
```
46+
```dart
4747
Stream<FileResponse> getImageFile(String url, {
4848
String key,
4949
Map<String, String> headers,
@@ -66,7 +66,7 @@ The cache manager is customizable by creating a new CacheManager. It is very imp
6666
Below is an example with other settings for the maximum age of files, maximum number of objects
6767
and a custom FileService. The key parameter in the constructor is mandatory, all other variables are optional.
6868

69-
```
69+
```dart
7070
class CustomCacheManager {
7171
static const key = 'customCacheKey';
7272
static CacheManager instance = CacheManager(

flutter_cache_manager/lib/src/cache_store.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'dart:async';
22
import 'dart:io';
33

44
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
5-
import 'dart:io' as io;
65

76
///Flutter Cache Manager
87
///Copyright (c) 2019 Rene Floor
@@ -187,7 +186,7 @@ class CacheStore {
187186
if (_futureCache.containsKey(cacheObject.key)) {
188187
await _futureCache.remove(cacheObject.key);
189188
}
190-
final file = io.File(cacheObject.relativePath);
189+
final file = await fileSystem.createFile(cacheObject.relativePath);
191190

192191
if (file.existsSync()) {
193192
try {

flutter_cache_manager/test/cache_store_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,24 @@ void main() {
402402
verify(config.mockRepo
403403
.deleteAll(argThat(containsAll([co1.id, co2.id, co3.id])))).called(1);
404404
});
405+
406+
test('Store should delete file when remove cached file', () async {
407+
var config = createTestConfig();
408+
var store = CacheStore(config);
409+
410+
await config.returnsFile(fileName);
411+
config.returnsCacheObject(fileUrl, fileName, validTill, id: 1);
412+
413+
var cacheObject = await store.retrieveCacheData(fileUrl);
414+
415+
expect(cacheObject, isNotNull);
416+
var fileInfo = await store.getFile(cacheObject!.key);
417+
expect(await fileInfo?.file.exists(), isTrue);
418+
419+
await store.removeCachedFile(cacheObject);
420+
421+
expect(await fileInfo?.file.exists(), isFalse);
422+
});
405423
});
406424
}
407425

flutter_cache_manager_firebase/lib/src/firebase_cache_manager.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class FirebaseCacheManager extends CacheManager {
99
static const key = 'firebaseCache';
1010

1111
static final FirebaseCacheManager _instance =
12-
FirebaseCacheManager._(retryOptions: retryOptions, bucket: bucket);
12+
FirebaseCacheManager._(retryOptions: _retryOptions, bucket: _bucket);
1313

14-
static RetryOptions? retryOptions;
14+
static RetryOptions? _retryOptions;
1515

16-
static String? bucket;
16+
static String? _bucket;
1717

1818
factory FirebaseCacheManager({RetryOptions? retryOptions, String? bucket}) {
19-
bucket = bucket;
20-
retryOptions = retryOptions;
19+
_bucket = bucket;
20+
_retryOptions = retryOptions;
2121
return _instance;
2222
}
2323

flutter_cache_manager_firebase/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ environment:
99
dependencies:
1010
flutter:
1111
sdk: flutter
12-
flutter_cache_manager: ^3.4.0
12+
flutter_cache_manager: ^3.4.1
1313
firebase_storage: '>=12.0.0 <13.0.0'
1414
path_provider: ^2.1.4
1515
path: ^1.9.0

0 commit comments

Comments
 (0)