Ad
FutureBuilder Widget Returns Instance Of 'DataSnapshot' Only With Firebase RealtimeDatabase
I unable to use FutureBuilder and StreamBuilder widgets with Firebase RealTimeDatabase i tried many time to retrieve the data in my RealTimeDatabase every time it returns in debug print
ConnectionState.done value is Instance of 'DataSnapshot',
FutureBuilder(
initialData: 1,
future: FirebaseDatabase.instance.reference().child('hello').once(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
print(snapshot);
return Text(snapshot.data.toString());
},
),
Ad
Answer
Your getting the instance of the data snapshot so just add, .value
.
FutureBuilder(
initialData: 1,
future: FirebaseDatabase.instance.reference().child('hello').once(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
print(snapshot);
return Text(snapshot.data.value.toString());//just add value here
},
),
Ad
source: stackoverflow.com
Related Questions
- → How can I query Firebase for an equalTo boolean parameter?
- → How can I access nested data in Firebase with React?
- → Firebase simple blog (confused with security rules)
- → Removing item in Firebase with React, re-render returns item undefined
- → AngularJS Unknown Provider Error (Firebase & AngularFire)
- → How do you pass top level component state down to Routes using react-router?
- → "this" is null in firebase query function in reactjs
- → Angular Module Failed to Load
- → Multiple dex files define Lcom/google/android/gms/internal/zzrx;
- → Joining Firebase tables in React
- → How can I make add firepad to my reactjs project?
- → How to use Cloud Functions for Firebase to prerender pages for SEO?
- → React.js component has null state?
Ad