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

Upgraded dependencies and code consistent with Firebase Storage 5. #20

Merged
merged 1 commit into from
Nov 6, 2020
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
10 changes: 5 additions & 5 deletions lib/src/cache_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,16 @@ class FirebaseImageCacheManager {
return null;
}

StorageReference getImageRef(
FirebaseImageObject object, FirebaseApp firebaseApp) {
Reference getImageRef(FirebaseImageObject object, FirebaseApp firebaseApp) {
FirebaseStorage storage =
FirebaseStorage(app: firebaseApp, storageBucket: object.bucket);
FirebaseStorage.instanceFor(app: firebaseApp, bucket: object.bucket);
return storage.ref().child(object.remotePath);
}

Future<void> checkForUpdate(
FirebaseImageObject object, FirebaseImage image) async {
int remoteVersion =
(await object.reference.getMetadata()).updatedTimeMillis;
(await object.reference.getMetadata()).updated.millisecondsSinceEpoch;
if (remoteVersion != object.version) {
// If true, download new image for next load
await this.upsertRemoteFileToCache(object, image.maxSizeBytes);
Expand Down Expand Up @@ -147,7 +146,8 @@ class FirebaseImageCacheManager {
Future<Uint8List> upsertRemoteFileToCache(
FirebaseImageObject object, int maxSizeBytes) async {
if (CacheRefreshStrategy.BY_METADATA_DATE == this.cacheRefreshStrategy) {
object.version = (await object.reference.getMetadata()).updatedTimeMillis;
object.version =
(await object.reference.getMetadata()).updated.millisecondsSinceEpoch;
}
Uint8List bytes = await remoteFileBytes(object, maxSizeBytes);
await putFile(object, bytes);
Expand Down
7 changes: 3 additions & 4 deletions lib/src/firebase_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ class FirebaseImage extends ImageProvider<FirebaseImage> {
return uri.path;
}

static StorageReference _getImageRef(
String location, FirebaseApp firebaseApp) {
FirebaseStorage storage =
FirebaseStorage(app: firebaseApp, storageBucket: _getBucket(location));
static Reference _getImageRef(String location, FirebaseApp firebaseApp) {
FirebaseStorage storage = FirebaseStorage.instanceFor(
app: firebaseApp, bucket: _getBucket(location));
return storage.ref().child(_getImagePath(location));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/image_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:firebase_storage/firebase_storage.dart';

class FirebaseImageObject {
int version;
StorageReference reference;
Reference reference;
String localPath;
final String remotePath;
final String bucket;
Expand Down
90 changes: 59 additions & 31 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,56 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.13"
version: "1.15.0-nullsafety.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
file:
dependency: transitive
description:
Expand All @@ -63,14 +70,14 @@ packages:
name: firebase
url: "https://pub.dartlang.org"
source: hosted
version: "7.3.0"
version: "7.3.2"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
version: "0.5.1"
firebase_core_platform_interface:
dependency: transitive
description:
Expand All @@ -91,7 +98,14 @@ packages:
name: firebase_storage
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
version: "5.0.0"
firebase_storage_platform_interface:
dependency: transitive
description:
name: firebase_storage_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -141,28 +155,28 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.8"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.3"
path:
dependency: "direct main"
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.1"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.11"
version: "1.6.24"
path_provider_linux:
dependency: transitive
description:
Expand All @@ -176,21 +190,28 @@ packages:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+3"
version: "0.0.4+6"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
version: "1.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+3"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
version: "1.9.2"
platform:
dependency: transitive
description:
Expand All @@ -204,7 +225,7 @@ packages:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.0.3"
process:
dependency: transitive
description:
Expand All @@ -218,7 +239,7 @@ packages:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.4+1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -230,14 +251,14 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety.2"
sqflite:
dependency: "direct main"
description:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.3.2+1"
sqflite_common:
dependency: transitive
description:
Expand All @@ -251,21 +272,21 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.5"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety.1"
synchronized:
dependency: transitive
description:
Expand All @@ -279,35 +300,42 @@ packages:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.17"
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.3"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.3"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
version: "0.1.2"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"
dart: ">=2.10.2 <2.11.0"
flutter: ">=1.22.2 <2.0.0"
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ dependencies:
sdk: flutter

firebase_core: ^0.5.0
firebase_storage: ^4.0.0
sqflite: ^1.3.1
firebase_storage: ^5.0.0
sqflite: ^1.3.2+1
path: ^1.7.0
path_provider: ^1.6.11
path_provider: ^1.6.24

dev_dependencies:
flutter_test:
Expand Down