createData method
Implementation
Future<bool> createData({
required String collection,
required Map<String, dynamic> data,
String? id,
bool isErrorDialog = true,
Function(String? message)? onError,
}) async {
// try {
if (id == null) {
return await _firestore
.collection(collection)
.add(data)
.then((value) => true)
.catchError((error) async {
if (isErrorDialog) {
GetxFire.openDialog.messageError(error.toString());
} else {
await GetxFire.hideProgressHud();
}
if (onError != null) onError(error);
return false;
});
} else {
return await _firestore
.collection(collection)
.doc(id)
.set(data)
.then((value) => true)
.catchError((error) async {
if (isErrorDialog) {
GetxFire.openDialog.messageError(error.toString());
} else {
await GetxFire.hideProgressHud();
}
if (onError != null) onError(error);
return false;
});
}
// } catch (e) {
// GetxFire.openDialog.messageError(e.toString());
// return false;
// }
}