The json (_data) returned in the onChanged method is the same object that is manipulated in the JsonEditor. Therefore, if you assign the json returned in the onChanged method to some variable somewhere and continue with more edits in the JsonEditor, the variable outside would also be changed as it's assigned by reference.
To fix this issue, you should not send the (_data) to onChanged method immediately.
Instead, copy it with _data is Map ? {...(_data as Map)} : [..._data] or with a better way and then send it to onChanged.
The
json
(_data) returned in theonChanged
method is the same object that is manipulated in theJsonEditor
. Therefore, if you assign thejson
returned in theonChanged
method to some variable somewhere and continue with more edits in the JsonEditor, the variable outside would also be changed as it's assigned by reference.To fix this issue, you should not send the (_data) to
onChanged
method immediately. Instead, copy it with_data is Map ? {...(_data as Map)} : [..._data]
or with a better way and then send it toonChanged
.