Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update dependencies for Firebase Cache Manager #415

Merged
merged 4 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions flutter_cache_manager_firebase/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
## [2.0.3] - 2024-07-23

* Updates dependencies ([#457](https://github.com/Baseflow/flutter_cache_manager/pull/457))

## [2.0.2] - 2024-04-25

* Updates dependencies to their latest versions.

## [2.0.1] - 2021-08-27

* Update dependencies

## [2.0.0] - 2021-05-28

* Update to null safety

## [1.1.0] - 2021-01-14

* Update Firebase dependency

## [1.1.0-beta] - 2020-10-02

* Update CacheManager dependency to 2.x.x.

## [1.0.1] - Update firebase dependency

* Added support for version 4.x.x

## [1.0.0] - Initial release
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:retry/retry.dart';

import 'firebase_http_file_service.dart';

Expand All @@ -7,12 +8,18 @@ import 'firebase_http_file_service.dart';
class FirebaseCacheManager extends CacheManager {
static const key = 'firebaseCache';

static final FirebaseCacheManager _instance = FirebaseCacheManager._();
static final FirebaseCacheManager _instance = FirebaseCacheManager._(null);

final RetryOptions? retryOptions;

factory FirebaseCacheManager() {
return _instance;
}

FirebaseCacheManager._()
FirebaseCacheManager.retry({this.retryOptions = const RetryOptions()})
: super(Config(key,
fileService: FirebaseHttpFileService(retryOptions: retryOptions)));

FirebaseCacheManager._(this.retryOptions)
: super(Config(key, fileService: FirebaseHttpFileService()));
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:retry/retry.dart';

/// [FirebaseHttpFileService] is another common file service which parses a
/// firebase reference into, to standard url which can be passed to the
/// standard [HttpFileService].
class FirebaseHttpFileService extends HttpFileService {
final RetryOptions? retryOptions;

FirebaseHttpFileService({
this.retryOptions,
});

@override
Future<FileServiceResponse> get(String url,
{Map<String, String>? headers}) async {
var ref = FirebaseStorage.instance.ref().child(url);
var downloadUrl = await ref.getDownloadURL();

String downloadUrl;
if (retryOptions != null) {
downloadUrl = await retryOptions!.retry(
() async => await ref.getDownloadURL(),
retryIf: (e) => e is FirebaseException,
);
} else {
downloadUrl = await ref.getDownloadURL();
}
return super.get(downloadUrl);
}
}
1 change: 1 addition & 0 deletions flutter_cache_manager_firebase/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies:
firebase_storage: '>=12.0.0 <13.0.0'
path_provider: ^2.1.2
path: ^1.9.0
retry: ^3.1.2

dev_dependencies:
flutter_lints: ^4.0.0
Expand Down