Hassan Naveed
Hassan Naveed

Reputation: 155

Undefined name 'storage'. Try correcting the name to one that is defined, or defining the name

I'm makiing a mthod to Retrieve image from firebase storage,please tell me how i can solve this error

Future<List<Map<String, dynamic>>> _loadImage() async {
        List<Map<String, dynamic>> files = [];
    
        final ListResult result = await storage.ref('pizza').list();//Undefined name 'storage'.
    Try correcting the name to one that is defined, or defining the name.
        final List<Reference> allFiles = result.items;
    
        await Future.forEach<Reference>(allFiles, (file) async {
          final String fileUrl = await file.getDownloadURL();
          final FullMetadata fileMeta = await file.getMetadata();
          files.add({
            "url": fileUrl,
          });
        });
    
        return files;
      }

Upvotes: 0

Views: 733

Answers (1)

triple7
triple7

Reputation: 883

You're missing the definition of the storage variable. Did you just copy-paste this into your code from somewhere? Try using FirebaseStorage.instance instead.

Upvotes: 1

Related Questions