deleteData method

Future<void> deleteData({
  1. required String collection,
  2. required String id,
  3. FileModel? photo,
  4. bool isErrorDialog = true,
  5. dynamic onError(
    1. String? message
    )?,
})

Implementation

Future<void> deleteData({
  required String collection,
  required String id,
  FileModel? photo,
  bool isErrorDialog = true,
  Function(String? message)? onError,
}) async {
  // try {
  return await _firestore
      .collection(collection)
      .doc(id)
      .delete()
      .then((_) async {
    if (photo != null) {
      await StorageService().deleteFile(photo.filename!,
          fileType: photo.type!, folder: photo.folder!);
    }
  }).catchError((error) async {
    if (isErrorDialog) {
      GetxFire.openDialog.messageError(error.toString());
    } else {
      await GetxFire.hideProgressHud();
    }
    if (onError != null) onError(error);
    return null;
  });
  // } catch (e) {
  //   GetxFire.openDialog.messageError(e.toString());
  //   rethrow;
  // }
}