I have problem with updating variable since it also affect its parent. I am trying to remove List item from child but it also removing the parent data.
Here is my code
Future<void> ChangeSubCategory({required String value}) async {
if (this.mounted) {
setState(() {
if (!_subCategory.contains(value)) {
if (value == 'all') {
_subCategory = _categoryOutput[_category]; => set _subCategory from parent List
} else {
_subCategory.add(value);
}
} else if (_subCategory.contains(value)) {
_subCategory.remove(value); => When doing this one, the parent _categoryOutput also affected
}
UpdateFilter();
});
}
}
What is the safest way if we want to replicate variable from parent? since in flutter it also update the parent when we update child variable. Thank you.