The class 'FirebaseStorage' doesn't have an unnamed constructor

211

According to the documentation Doug linked, creating a FirebaseStorage object for a specific bucket is done with:

firebase_storage.FirebaseStorage storage =
  firebase_storage.FirebaseStorage.instanceFor(
      bucket: 'secondary-storage-bucket');
Share:
211
user14845003
Author by

user14845003

Updated on January 04, 2023

Comments

  • user14845003
    user14845003 over 1 year

    i've cloned a git to build an app. In the storage section i've the following code:

    class StorageRepo {
      FirebaseStorage storage = FirebaseStorage(
        storageBucket: ''
      );
    

    However it give me the error:

    The class 'FirebaseStorage' doesn't have an unnamed constructor.

    What's wrong?

    • user14845003
      user14845003 about 2 years
      This is what i've added for the storage, not what i've copied!
  • user14845003
    user14845003 about 2 years
    i've read that and tryied... but i get the error "Undefined name 'firebase_storage'
  • Frank van Puffelen
    Frank van Puffelen about 2 years
    My guess is that you're import looks different than the one in that same documentation page then: import 'package:firebase_storage/firebase_storage.dart' as firebase_storage;. If you just used import 'package:firebase_storage/firebase_storage.dart', you can also drop the firebase_storage from the class and constructor references in your code.