updateData method

Future<bool> updateData({
  1. required String collection,
  2. required String? id,
  3. required Map<String, dynamic> data,
  4. bool isErrorDialog = true,
  5. void onError(
    1. FirebaseException firebaseException
    )?,
})

Implementation

Future<bool> updateData({
  required String collection,
  required String? id,
  required Map<String, dynamic> data,
  bool isErrorDialog = true,
  void Function(FirebaseException firebaseException)? onError,
}) async {
  // try {
  return await _firestore
      .collection(collection)
      .doc(id)
      .update(data)
      .then((value) => true)
      .catchError((error) async {
    if (isErrorDialog) {
      GetxFire.openDialog.messageError(error.message.toString(),
          title: error.code.toString());
    } else {
      await GetxFire.hideProgressHud();
    }
    if (onError != null) onError(error);
    return false;
  });
  // } catch (e) {
  //   GetxFire.openDialog.messageError(e.toString());
  //   return false;
  // }
}