Reputation: 1780
Is there any way to use firebase RTDB(not FireStore) with Flutter Stream Builder. I search many times but I cannot find a single example. all the example are using cloud fire store.
Upvotes: 7
Views: 7821
Reputation: 1277
You can refer to this medium article, they have explained how to use StreamBuilders with Firebase RTDB.
In the meantime, here's a piece code derived from the same article...
//first make a reference to your firebase database
var recentJobsRef = FirebaseDatabase.instance
.reference()
.child('recent')
.orderByChild('created_at')
.limitToFirst(10);
//then use StreamBuilders like this
StreamBuilder(
stream: recentJobsRef.onValue,
builder: (BuildContext context, snapshot) {
if(snapshot.hasData) => return "Has Data";
else if(snapshot.hasError) => return "Error";
}
Upvotes: 14