Reputation: 11
I want to access data from my firebase to display in my app. And I have been working on this app with Firebase for a few days, but today I got an error saying my code :
StreamBuilder<QuerySnapshot>(
stream:
FirebaseFirestore.instance.collection('videos').snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return Text('Something went wrong!');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator());
}
return ListView(
shrinkWrap: true,
physics: ClampingScrollPhysics(),
children:
snapshot.data!.docs.map((DocumentSnapshot document) {
Map<String, dynamic> data =
document.data()! as Map<String, dynamic>;
return GestureDetector(
onTap: () {},
child: HomeDisplayScreen(
videoLink: data['videoLink'],
imageUrl: data['imageUrl'],
title: data['title'],
likes: data['likes'],
),
);
}).toList(),
);
})
the error:
W/Firestore( 8345): (24.1.2) [Firestore]: Listen for Query(target=Query(videos order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
W/Firestore( 8345): (24.1.2) [Firestore]: Listen for Query(target=Query(users/*****@gmail.com order by __name__);limitType=LIMIT_TO_FIRST) failed: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
I/flutter ( 8345): [cloud_firestore/permission-denied] The caller does not have permission to execute the specified operation.
I also changed my security rules to this
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write : if true;
}
}
}
Still, I am getting the same error
Upvotes: 0
Views: 942
Reputation: 11
I don't know if you already fix your problem but the error you got, was because of your Firestore rules so to fix it go into firestore rules and change them.
Upvotes: 1
Reputation: 2521
Inside projectFolder/android/app/src/main/AndroidManifest.xml
try add the following and rebuild your app:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Upvotes: 0