I have a List variable to store the last saved value of some data. When this variable is different from the current data, it updates it to match. But, when I check if they are the same, they always are! When the data variable is updated, I check both and the last saved variable has changed as well. Does Dart link the variables somehow when I assign their values?
I tries printing both variables before I do the check, to make sure that's not changing them, but they are still the same at the instant the data variable is changed.
print("checking if data updated");
print(lastSavedData);
print(datas);
if (lastSavedData == datas) {
print("no new data");
} else {
print("new data is there");
saveData();
lastSavedData = datas;
}
I/flutter ( 8751): checking if data updated
I/flutter ( 8751): []
I/flutter ( 8751): []
I/flutter ( 8751): no new data
I/flutter ( 8751): checking if data updated
I/flutter ( 8751): [{name: Fu, notes: , goodness: 0}]
I/flutter ( 8751): [{name: Fu, notes: , goodness: 0}]
I/flutter ( 8751): no new data