mattreid1 / firebase_image Goto Github PK
View Code? Open in Web Editor NEWπ₯ Cached Flutter ImageProvider for Firebase Cloud Storage
Home Page: https://pub.dev/packages/firebase_image
License: ISC License
π₯ Cached Flutter ImageProvider for Firebase Cloud Storage
Home Page: https://pub.dev/packages/firebase_image
License: ISC License
It seems that cache is no longer working. I use latest updates from Firebase.
If I state that "shouldCache: false" then I still get the old image from storage even though I have overwritten it with a new image and can also see that Created and Modified dates are updated in Storage.
If I restart my app (NOT hot-reload) then it seems to get the new image... ? But normal use of app does not use this approach.
Please check this issue as this is why I use your package... and cache seems to broken...
Thanks for great work and I love your package, Jan
There is no exception named StorageException to catch the exception if there is no file located on that location.
Please help.
They've just release a new version of the FlutterFire libraries, firebase_storage has reached version 6.0.0.
There should be no significant changes since 5.0.0, just updating the pubspec.yaml should be enough.
It would be nice to have the dependency updated soon since the current one prevents from upgrading all the other FlutterFire dependencies in the app!
Thank you!
Currently Firebase Image does not work with the web.
I received the following error when I tried it on web:
ββββββββ Exception caught by image resource service ββββββββββββββββββββββββββββ
MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite)
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
It is working perfectly on iOS and Android.
my app was crashing every time firebase_image was loading picture stating TypeError (type 'Null' is not a subtype of type 'Reference'). after looking into the code, it's the FirebaseImageObject.fromMap(Map<String, dynamic> map) method in image_object.dart causing the error because it's called with no value given to the reference key.
potential solution: make Reference variable in FirebaseImageObject nullable and it solves the problem.
Firebase Storage was upgraded. Can we get this bumped to get compatible?
Because firebase_image 0.2.0 depends on firebase_storage ^4.0.0 and no versions of firebase_image match >0.2.0 <0.3.0, firebase_image ^0.2.0 requires firebase_storage ^4.0.0.
So, because depends on both firebase_storage ^5.0.0 and firebase_image ^0.2.0, version solving failed.
pub get failed (1; So, because depends on both firebase_storage ^5.0.0 and firebase_image ^0.2.0, version solving failed.)
Getting error when compiling in latest stable (1.12.13)
pub.dartlang.org/firebase_image-0.1.4/lib/src/firebase_image.dart:107:24: Error: The method 'FirebaseImage.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'.
ImageStreamCompleter load(FirebaseImage key) {
^
../../../../_mobile/flutter/packages/flutter/lib/src/painting/image_provider.dart:403:24: Context: This is the overridden method ('load').
ImageStreamCompleter load(T key, DecoderCallback decode);
firebase_storage
was recently upgraded. When a project that uses this library tries to upgrade, it gets this build issue:
Because firebase_image 0.1.6 depends on firebase_storage ^3.1.0 and no versions of firebase_image match >0.1.6 <0.2.0, firebase_image ^0.1.6 requires firebase_storage ^3.1.0.
Can we please get an upgrade of firebase_image
that references firebase_storage: ^4.0.0
?
when the filename contains umlauts like Γ€ ΓΆ ΓΌ I get the following error:
com.google.firebase.storage.StorageException: Object does not exist at location.
I tried downloading the same file with pure firebase storage and that worked.
The plugin throws an exception even though I'm setting maxSizeBytes
to 10MB.
This is the complete output:
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: PlatformException(download-size-exceeded, Size of the downloaded file exceeds the amount of memory allocated for the download., {code: download-size-exceeded, message: Size of the downloaded file exceeds the amount of memory allocated for the download., nativeErrorMessage: Attempted to download object with size of 8433073 bytes, which exceeds the maximum size of 2500000 bytes. Consider raising the maximum download size, or using [FIRStorageReference writeToFile:], nativeErrorCode: -13032}, null)
And this is the widget:
Container(
margin: const EdgeInsets.only(top: 15),
height: 250,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
image: DecorationImage(
image: FirebaseImage(
path,
cacheRefreshStrategy: CacheRefreshStrategy.NEVER, // Switch off update checking
maxSizeBytes: MAX_SIZE_BYTES, // 10MB max file size (default: 2.5MB)
),
fit: BoxFit.cover,
),
),
);
Edit:
Solved. I was precaching the image in initState
and needed to add the maxSizeBytes
argument there too:
@override
void initState() {
super.initState();
FirebaseImage(
path,
cacheRefreshStrategy: CacheRefreshStrategy.NEVER, // Switch off update checking
maxSizeBytes: MAX_SIZE_BYTES, // 10MB max file size (default: 2.5MB)
).preCache();
}
Question: Isn't it redundant to create the same widget twice?
(e.g. Image cached locally)
no warning when I run my own app.
(e.g. App crashed with stack trace provided)
just warning,, one time or twice in the console.
When I just start an app,,, with real device(android tablet)
flutter --version
) 2.0.2If applicable, please add screenshots to help explain your problem.
(optional) Add any other context about the problem here.
It just only warning,,, but I cannot confirm a situation when I face a certain problem..
So please check this problem. Thank you.
Image fetched
Throws: StorageException has occurred. Object does not exist at location
Yeah I know, but a co-worker uploaded a bunch of images some of which have a space in the name - sic :)
I can't update to newest Firebase versions.
Problem:
Because firebase_image 1.1.1 depends on firebase_storage ^10.0.5 and no versions of firebase_image match >1.1.1 <2.0.0, firebase_image ^1.1.1 requires firebase_storage ^10.0.5.
also
Because firebase_image 1.1.1 depends on firebase_core ^1.7.0 and no versions of firebase_image match >1.1.1 <2.0.0, firebase_image ^1.1.1 requires firebase_core ^1.7.0.
Can you update package to include newest Firebase versions?
Thanks.
Didn't see Web listed, any compatibility issues with using this for web?
We'd love to be able to fire off a command to pre-cache a Firestore image url.
ie
final url = "gs://vgl-xxxa.appspot.com/users/xxxxx/avatars/xx-xx-xx-a2fb-xx.jpg";
FirebaseImageCacheManager.precache(url);
Consider the following code:
Future<FirebaseImageObject> get(String uri, FirebaseImage image) async {
List<Map> maps = await db.query(
table,
columns: null,
where: 'uri = ?',
whereArgs: [uri],
);
if (maps.length > 0) {
FirebaseImageObject returnObject =
new FirebaseImageObject.fromMap(maps.first);
returnObject.reference = getImageRef(returnObject, image.firebaseApp);
if (CacheRefreshStrategy.BY_METADATA_DATE == this.cacheRefreshStrategy) {
checkForUpdate(returnObject, image); // Check for update in background
}
return returnObject;
}
return null;
}
StorageReference getImageRef(
FirebaseImageObject object, FirebaseApp firebaseApp) {
FirebaseStorage storage =
FirebaseStorage(app: firebaseApp, storageBucket: object.bucket);
return storage.ref().child(object.remotePath);
}
The code seems to be using bucket
and remotePath
to rehydrate the uri
into a StorageReference
. Why not simply call FirebaseStorage.getReferenceFromUrl
? (And then you can avoid the redundancy of bucket
and remotePath
.)
I also see that the code is leveraging the firebaseApp
, but is that necessary when you have a fully qualified Uri
?
update firebase_storage to ^10.0.0
Hi,
For example, path "gs://example-project/myimages/imagename with spaces.jpeg" returns:
PlatformException(object-not-found, No object exists at the desired reference., {code: object-not-found, message: No object exists at the desired reference., nativeErrorMessage: Object myimages/imagename%20with%20spaces.jpeg does not exist., nativeErrorCode: -13010}, null)
How can I handle it ? suppose that I don't have control over the image name.
By the way, excellent job with this firebase_image plugin!
I like what you've created with FirebaseImage. I am running into a little struggle because I have a StorageReference
to my image instead of a fully qualified location (with gs:
prefix).
Would it be possible to get an overloaded version that accepts a StorageReference
instead of the fully qualified location
?
Or is there a good way to translate a StorageReference
into a fully qualified location
? The getBucket
method seems like the translation, but the fact that it is async
is a problem because I'm trying to minimize jank, so if I wrap this in a FutureBuilder
, it ends up creating jank -- it would be best to have this as part of the ImageProvider
since it is already asynchronous. (I'm already using FadeInImage
and BlurHash
to get a sweet effect.)
I would like to show a blurhash of the image before it completes loading. See https://pub.dev/packages/flutter_blurhash
The easiest way would be to have an optional parameter in the constructor, defining a placeholder widget?
Or any other thoughts on how to easily achieve this?
Any thoughts to a method for flushing the cache to refresh the file? Perhaps this is already self evident to most. i'm just a novice coder. Thanks for the tool. It's helpful!
Hey, please update the firebase dependency.
@mattreid1 @thearaks @awhitford
Thanks in advance.
Hi, thanks for the great plugin, it works wonders!. I would l like to show a progress indicator, or an icon while the image is loading.
Currently, I am putting the FirebaseImage inside an Image widget, but the Image widget doesn't pick up the progress in the loadingBuilder. Any help would be much appreciated!
Thank you for maintaining this great library.
Iβm looking for a way to show a fallback image when the specified GCS URL is unavailable. In my app thereβs a possibility that a image is deleted in GSC but it is still referenced by FirebaseImage widget.
Current behavior I observed in my app: FirebaseImage uses cached data if available; otherwise it throws exception (no image). I wish thereβs a way to show some error-indicating image in such case.
If itβs not available right now, Iβm thinking to contribute a PR.
I have a scenario where a user may have uploaded a headshot image. There is no exists
method for StorageReference
, so the only way for one to really know if the user has an image is to try and download it. Alas, then I end up with messy stack traces, like:
flutter: βββ‘ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE βββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: The following PlatformException was thrown resolving an image codec:
flutter: PlatformException(Error -13010, FIRStorageErrorDomain, Object
flutter: headshots/QvCAc4WkJd8k0QthAUl1/headshot.jpg does not exist.)
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
flutter: #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
flutter: <asynchronous suspension>
flutter: #2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
flutter: #3 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:356:48)
flutter: #4 StorageReference.getMetadata (package:firebase_storage/src/storage_reference.dart:162:10)
flutter: #5 FirebaseImageCacheManager.upsertRemoteFileToCache (package:firebase_image/src/cache_manager.dart:145:48)
flutter: #6 FirebaseImage._fetchImage (package:firebase_image/src/firebase_image.dart:93:36)
flutter: <asynchronous suspension>
flutter: #7 FirebaseImage._fetchImageCodec (package:firebase_image/src/firebase_image.dart:106:38)
flutter: #8 FirebaseImage.load (package:firebase_image/src/firebase_image.dart:117:18)
flutter: #9 ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:501:13)
flutter: #10 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:359:22)
flutter: #11 ImageProvider.resolveStreamForKey (package:flutter/src/painting/image_provider.dart:499:80)
flutter: #12 ScrollAwareImageProvider.resolveStreamForKey (package:flutter/src/widgets/scroll_aware_image_provider.dart:106:19)
flutter: #13 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:330:9)
flutter: #14 ImageProvider._createErrorHandlerAndKey.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:460:26)
flutter: #15 SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:41:29)
flutter: #16 ImageProvider._createErrorHandlerAndKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:457:11)
flutter: #20 ImageProvider._createErrorHandlerAndKey (package:flutter/src/painting/image_provider.dart:449:16)
flutter: #21 ImageProvider.resolve (package:flutter/src/painting/image_provider.dart:327:5)
flutter: #22 _ImageState._resolveImage (package:flutter/src/widgets/image.dart:1099:16)
flutter: #23 _ImageState.didChangeDependencies (package:flutter/src/widgets/image.dart:1052:5)
(and it keeps going)
It appears that the getMetadata
call is causing the Not Found Exception.
firebase_image/lib/src/cache_manager.dart
Line 145 in d5cc7df
Can something be done to suppress this extensive stack trace output? I would be open to passing a flag that indicated that a File not found is OK; or perhaps an onFileNotFound
handler?
My code can really ignore it. The image, since it does not exist, is never provided, so my image place holder is simply never replaced. But the excessive stack traces are a huge distraction and it cries wolf.
Just used this library with most recent null safety version and getting this in my console over and over again.
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_image-1.0.1/lib/src/cache_manager.dart:29:13:
Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
join((await getDatabasesPath())!, dbName),
That's all I have.
Sorry this is more a question than an actual bug, but how does this package differ from cached_network_image?
Currently I am using cached_network_image
, getting the download URL of my Firebase Storage images.
Is it just about how it checks the metadata for file updates?
Hey π
Thanks for making this library, I've been looking for a good solution that doesn't use getDownloadURL()
for a while!
My use case has image assets that are permanent - the image binary at a given path will never change. I'm looking to implement a flag that disables the version check logic to save extra calls. Would you be happy if I contribute this?
The Firebase Image should be able to update the local DB cache.
The Firebase Image tries to update the local DB cache, but fails.
Android Studio reports the following error:
`======== Exception caught by image resource service ================================================
The following ArgumentError was thrown resolving an image codec:
Invalid argument: Instance of 'Reference'
When the exception was thrown, this was the stack:
#0 StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:419:7)
#1 StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:409:9)
#2 StandardMessageCodec.writeValue. (package:flutter/src/services/message_codecs.dart:416:9)
#3 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:397:8)
#4 StandardMessageCodec.writeValue (package:flutter/src/services/message_codecs.dart:414:13)
...
====================================================================================================`
Flutter 2.2.0 β’ channel stable β’ https://github.com/flutter/flutter.git
Framework β’ revision b22742018b (3 weeks ago) β’ 2021-05-14 19:12:57 -0700
Engine β’ revision a9d88a4d18
Tools β’ Dart 2.13.0
I found this error on MacOS (Big Sur), but not on Linux Mint.
when i was upload my profile image its showing true but exit app and reopen app still showing old photo and after i m trying exit app re open coming true photo.its not working properly. and no showing error.
FirebaseImage("gs://****/${}/profileUrl",cacheRefreshStrategy: CacheRefreshStrategy.BY_METADATA_DATE,shouldCache: true)
/C:/Users/kuk/Documents/sdk/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_image-1.0.1/lib/src/cache_manager.dart:29:13: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
join((await getDatabasesPath())!, dbName),
^
In my flutter application user has to submit or upload 3 images and 2 PDFs randomly in each form.
When the user opens the retrieved page or home screen,the user should be always able to see the saved or uploaded or retrieved images .
Those PDFs and images should remain permanent.
Please fix my issue How to achieve this functionality.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.