skip to Main Content

I have a folder called ‘pecs’ in Firebase object storage, and it contains a file:

enter image description here

However, calling listAll on its reference returns an empty list:

FirebaseStorage storage = FirebaseStorage.instance;
Reference ref = storage.ref().child("pecs");
ListResult list = await ref.listAll();
setState(() {
  _items = list.items;
});

_items in the above code ends up empty. I have enabled Firebase in main:

  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

What else may be missing?

2

Answers


  1. Chosen as BEST ANSWER

    The problem was caused by a wrong selection of the Firebase project while running flutterfire configure. Re-running with the right project fixed the problem.


  2. This might help.

    In the image you posted check the "Rules" tab on your tab bar

    It will look something like this

    service firebase.storage {
      match /b/{bucket}/o {
        match /{allPaths=**} {
          allow read, write: false;
        }
      }
    }
    

    update it to

    service firebase.storage {
      match /b/{bucket}/o {
        match /{allPaths=**} {
          allow read, write: true;
        }
      }
    }
    

    This update will allow your flutter project to access your images in firestorage.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search