The method 'getReferenceFromUrl' isn't defined for the type 'FirebaseStorage'

223

The getReferenceFromUrl is depracated as you can see here.

You would need to call ref() with the path to the file in the storage.

As @puff mentioned in the comment the new API call would be refFromURL('your_download_url')

Share:
223
eight
Author by

eight

Updated on December 29, 2022

Comments

  • eight
    eight over 1 year

    I have a problem with Firebase. I learned flutter using a video on youtube about how to delete data and images from firebase. And I have one function that deletes the image from firestore but I cannot use getReferenceFromUrl(). It shows the error

    The method 'getReferenceFromUrl' isn't defined for the type 'FirebaseStorage'.

    deleteFood(Food food, Function foodDeleted) async {
      if (food.image != null) {
        Reference storageReference =
            await FirebaseStorage.instance.getReferenceFromUrl(food.image);
    
        print(storageReference.path);
    
        await storageReference.delete();
    
        print('image deleted');
      }
    
      await FirebaseFirestore.instance.collection('Foods').doc(food.id).delete();
      foodDeleted(food);
    }
    
  • Frank van Puffelen
    Frank van Puffelen about 3 years
    The most likely replacement method for getReferenceFromUrl is actually refFromURL. ref() takes a path, while refFromURL takes a download URL as far as I can tell.