xxxxxxxxxx
Open the pubspec.
Add your Flutter application to Firebase by clicking on the Android icon.
Add your application's package name as shown in the image below.
You can find your package name in the app-level – build.
Download the google-services.
Paste classpath 'com.
xxxxxxxxxx
FirebaseDatabase database = FirebaseDatabase.instance;
DatabaseReference ref = FirebaseDatabase.instance.ref("users/123");
DatabaseReference starCountRef = FirebaseDatabase.instance.ref('test');
starCountRef.onValue.listen((DatabaseEvent event) {
final datasnap = event.snapshot.value as Map<String, dynamic>;
print(datasnap['double']);
});
xxxxxxxxxx
static Future<List<AustinFeedsMeEvent>> _getEventsFromFirestore() async {
CollectionReference ref = Firestore.instance.collection('events');
QuerySnapshot eventsQuery = await ref
.where("time", isGreaterThan: new DateTime.now().millisecondsSinceEpoch)
.where("food", isEqualTo: true)
.getDocuments();
HashMap<String, AustinFeedsMeEvent> eventsHashMap = new HashMap<String, AustinFeedsMeEvent>();
eventsQuery.documents.forEach((document) {
eventsHashMap.putIfAbsent(document['id'], () => new AustinFeedsMeEvent(
name: document['name'],
time: document['time'],
description: document['description'],
url: document['event_url'],
photoUrl: _getEventPhotoUrl(document['group']),
latLng: _getLatLng(document)));
});
return eventsHashMap.values.toList();
}
xxxxxxxxxx
import 'package:firebase_database/firebase_database.dart';
final DatabaseReference databaseReference = FirebaseDatabase.instance.reference();
void readDataFromDatabase() {
databaseReference.once().then((DataSnapshot snapshot) {
if (snapshot.value != null) {
Map<dynamic, dynamic> map = snapshot.value;
// Process the data using the map
// ...
}
});
}
xxxxxxxxxx
Open the pubspec.
Add your Flutter application to Firebase by clicking on the Android icon.
Add your application's package name as shown in the image below.
You can find your package name in the app-level – build.
Download the google-services.
Paste classpath 'com.