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.
After you have integrated Firebase to your Flutter application and adding firebase_database as a dependency, you should be able to use Firebase Realtime Database by adding the import below. In order to perform data operations, you need to get the DatabaseReference object, which refers to a particular location (node) in the database.
Firebase helps developers to build and run their apps successfully, its backend developed by Google. Firebase is very easy to use for beginners, it provides many functionalities like Firebase Authentication, Cloud Firestore, Realtime Database, Firebase Storage, etc which help to build and optimize the application.
Realtime Database is the clear choice as it’s cheaper, easier to use and faster to run. Check out the full list of comparisons on Google’s product page. Switch to our Cloud Firestore tutorial if you’re looking to explore the Firestore solution. Before you can use any of Google’s cloud services, you have to set up a project on the Firebase Console.
Google’s Flutter SDK can be used to develop apps that give native UI experience for both Android and iOS platforms. To write apps using Flutter, you have to use Dart programming language. Firebase Realtime Database is a cloud-hosted database with data stored as JSON.
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";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With