Firestore ConnectionState is in Waiting state forever in flutter app
You may revise security settings in Firebase
console.
If you created the database in production mode (not testing), it comes with security rules that might block any connection until you allow so.
Open the Rules
tab in the database screen, (JUST TO TEST -> Make allow read, write; as below )
If it works, just consider reading about the security rules and set it appropriately as per your needs.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Pratik
Hello, I am currently working as a Software Engineer at Microsoft in Redmond, WA. I have previously worked with SAP Ariba, VivaLnk, and an enterprise software company, eQ Technologic. I have experience working on back-end technologies like Spring Framework, JPA, ActiveMQ etc. as well as front-end technologies like JavaScript, HTML, CSS, and frameworks like Angular, Backbone, and Marionette. Having worked in startups and large enterprise companies, I have a blend of maintaining the pace of development while following the processes. I bring with me 4+ yrs of Software Development expertise & also lots of positive energy!
Updated on December 13, 2022Comments
-
Pratik over 1 year
I am trying to fetch records from the Firestore database and show it in the Flutter app.
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Hello'), actions: <Widget>[ IconButton(icon: Icon(Icons.list), onPressed: _pushSaved) ]), drawer: _buildDrawer(), body: _buildCarpoolsList(), ); } Widget _buildCarpoolsList() { return StreamBuilder<QuerySnapshot>( stream: Firestore.instance.collection("carpools").snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) { return CircularProgressIndicator(); } else { var _carpools = snapshot.data.documents; return ListView( padding: const EdgeInsets.all(16.0), children: _deserializeCarpools(_carpools)); } }); }
In the
_buildCarpoolsList()
function thesnapshot.ConnectionState
is alwaysConnectionState.waiting
, and the function returnsCircularProgressBar()
.I have got a collection
carpools
in the FireStore database with a few records in it.I have set the firestore database rules to allow all.
rules_version = '2'; service cloud.firestore { match /** { allow read, write: if true; } }
Edit: My Firebase authentication works. (If that helps)
What could be missing here?