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

fixed null error #34

Closed
wants to merge 1 commit into from
Closed
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 @@ -89,8 +89,8 @@ class FirebaseImageCacheManager {
whereArgs: [uri],
);
if (maps.length > 0) {
FirebaseImageObject returnObject =
FirebaseImageObject.fromMap(maps.first);
FirebaseImageObject returnObject = FirebaseImageObject.fromMap(
maps.first); // Nullsafety error (reference is null)
returnObject.reference = getImageRef(returnObject, image.firebaseApp);
if (CacheRefreshStrategy.BY_METADATA_DATE == this.cacheRefreshStrategy) {
checkForUpdate(returnObject, image); // Check for update in background
Expand All @@ -108,7 +108,7 @@ class FirebaseImageCacheManager {

Future<void> checkForUpdate(
FirebaseImageObject object, FirebaseImage image) async {
int remoteVersion = (await object.reference.getMetadata())
int remoteVersion = (await object.reference!.getMetadata())
.updated
?.millisecondsSinceEpoch ??
-1;
Expand Down Expand Up @@ -142,13 +142,13 @@ class FirebaseImageCacheManager {

Future<Uint8List?> remoteFileBytes(
FirebaseImageObject object, int maxSizeBytes) {
return object.reference.getData(maxSizeBytes);
return object.reference!.getData(maxSizeBytes);
}

Future<Uint8List?> upsertRemoteFileToCache(
FirebaseImageObject object, int maxSizeBytes) async {
if (CacheRefreshStrategy.BY_METADATA_DATE == this.cacheRefreshStrategy) {
object.version = (await object.reference.getMetadata())
object.version = (await object.reference!.getMetadata())
.updated
?.millisecondsSinceEpoch ??
0;
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;
Reference reference;
Reference? reference;
String? localPath;
final String remotePath;
final String bucket;
Expand Down