Giter VIP home page Giter VIP logo

firebase_image's People

Contributors

awhitford avatar blaugold avatar mattreid1 avatar stargazing-dino avatar thearaks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

firebase_image's Issues

Upgrade to latest firebase_storage

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?

Feature: Flag to disable version checking

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?

Exception: download-size-exceeded

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?

Redundancy between uri and bucket+remotePath ?

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 dependency to ^7.0.0

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!

Null Safety isn't done very well.

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.

Package needs dependency updates

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.

Feature request: easy way to pre-cache by url

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);

Gracefully handle File Not Exists

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.

object.version = (await object.reference.getMetadata()).updatedTimeMillis;

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.

Web Support

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.

'FirebaseImage.load' has fewer positional arguments than those of overridden method 'ImageProvider.load'

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);

Manually force cache flush or reset.

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!

TypeError (type 'Null' is not a subtype of type 'Reference')

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.

In my flutter application user has to submit or upload 3 images and 2 PDFs randomly.

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.

StorageReference instead of Location

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.)

Invalid argument: Instance of 'Reference'

Expected Behaviour

The Firebase Image should be able to update the local DB cache.

Actual Behaviour

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)
...
====================================================================================================`

Specifications

  • Version: 1.0.1
  • Device: NordOne Plus
  • Platform: Android
  • Flutter Version:

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.

Resolve Incompatibility with firebase_storage ^5.0.0

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.)

BY_METADATA_DATE

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)

Specifications

  • Version: *
  • Device: lg g4
  • Platform: Android
  • Flutter Version: * 1.20.2,

path with spaces returns object-not-found

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!

Icon progress indicator

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!

shouldCache seems to be broken

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

A way to show fallback image when the image is unavailable

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.

/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), ^

/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),
^

umlauts seem break the plugin

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.

Warning: Operand of null-aware operation '!' has type 'String' which excludes null.

Expected Behaviour

(e.g. Image cached locally)
no warning when I run my own app.

Actual Behaviour

(e.g. App crashed with stack trace provided)
just warning,, one time or twice in the console.

Steps to Reproduce the Problem

When I just start an app,,, with real device(android tablet)

Specifications

  • Version: (e.g. 0.1.4) = ^1.0.1
  • Device: (e.g. iPhone 6) = p10 HD
  • Platform: (e.g. Hummingbird) = Android 9
  • Flutter Version: (please enter the output of flutter --version) 2.0.2

Screenshots

210322

If applicable, please add screenshots to help explain your problem.

Additional Context

(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.

Cannot fetch image with space in the name

Expected Behaviour

Image fetched

Actual Behaviour

Throws: StorageException has occurred. Object does not exist at location

Steps to Reproduce the Problem

  1. Upload image to storgae with a space in the name
  2. Try to retrieve it

Additional Context

Yeah I know, but a co-worker uploaded a bunch of images some of which have a space in the name - sic :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.