From 2e490c4b5c39fd496009f3fc6a5297fdd9551b84 Mon Sep 17 00:00:00 2001 From: nabos440 <104625739+nabos440@users.noreply.github.com> Date: Sat, 22 Mar 2025 04:27:27 +0500 Subject: [PATCH] Update parse_array.dart This fixes the issue because the **_handleSingleResult()** function which handles the response for a single parse object in the **_ParseResponseBuilder** was calling **_notifyChildrenAboutSave();** so when **save()** was called on any object it called **_notifyChildrenAboutSaving();** first and then in the response when **_notifyChildrenAboutSave();** was called, the **_estimatedArrayBeforeSaving** had values and _savedArray was not set as empty. But in case of other queries where single object was returned like **getUpdatedUser()** or **fetch()** on any object it just called **_notifyChildrenAboutSave();** in the **_handleSingleResult()** function which resulted in **_savedArray** being set as empty since **_estimatedArrayBeforeSaving** was null. I just added the null safety and not empty check before setting the **_savedArray** to **_estimatedArrayBeforeSaving** so now the savedArray is never returned empty in the response and the issue is resolved. --- packages/dart/lib/src/objects/parse_array.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/dart/lib/src/objects/parse_array.dart b/packages/dart/lib/src/objects/parse_array.dart index f4ebf602..415de91b 100644 --- a/packages/dart/lib/src/objects/parse_array.dart +++ b/packages/dart/lib/src/objects/parse_array.dart @@ -68,9 +68,11 @@ class _ParseArray implements _Valuable, _ParseSaveStateAwareChild { @mustCallSuper void onSaved() { setMode = false; + if(_estimatedArrayBeforeSaving != null){ _savedArray.clear(); - _savedArray.addAll(_estimatedArrayBeforeSaving ?? []); + _savedArray.addAll(_estimatedArrayBeforeSaving!); _estimatedArrayBeforeSaving = null; + } if (_lastPreformedOperationBeforeSaving == lastPreformedOperation) { // No operations were performed during the save process