getData method
Implementation
Future<List<QueryDocumentSnapshot<Object?>>> getData({
required String collection,
String? ownerUID,
bool isErrorDialog = true,
Function(String? message)? onError,
}) async {
// try {
Query _query = _firestore.collection(collection);
if (ownerUID != null) {
_query = _query.where("ownerInfo.uid", isEqualTo: ownerUID);
}
QuerySnapshot _doc;
_doc = await _query
.orderBy("createdAt", descending: true)
.get()
.catchError((error) async {
printError(info: error);
if (isErrorDialog) {
await GetxFire.openDialog.messageError(error.message.toString(),
title: error.code.toString());
} else {
await GetxFire.hideProgressHud();
}
if (onError != null) onError(error);
// return this;
});
return _doc.docs;
// } catch (e) {
// GetxFire.openDialog.messageError(e.toString());
// rethrow;
// }
}