I need to show another widget if FirebaseAnimatedList query not return any data, so not only show blank screen, how can I do this?
I am using
if(snapshot.value != null){} and if(!snapshot.exists()) {}
but it does not work.
I need to show another widget if FirebaseAnimatedList query not return any data, so not only show blank screen, how can I do this?
I am using
if(snapshot.value != null){} and if(!snapshot.exists()) {}
but it does not work.
You need to check the size of the list of documents.
For example:
//check in Firebase - Realtime Database
final FirebaseDatabase _database = FirebaseDatabase(app: FirebaseApp.instance);
void checkEmptyList() async {
var data = await _database.reference().child('your_child').once();
if (data.value == null) {
//document without data
} else {
//document with data
}
}
//check in Firebase - Cloud Firestore
final Firestore _fireStore = Firestore.instance;
void checkEmptyList() async {
var doc = await _fireStore.collection("your_collections").getDocuments();
if (doc.documents.isEmpty) {
//document without data
} else {
//document with data
}
}