I use flutter web I put a checkbox for users. The problem is that the page contains a different TextField.So, in the event that the user selects one of the Checkbox options, a page refresh occurs.Then all TextField data is reloaded and all data that was previously inserted is deleted.The problem is caused by setState(()).But I can't delete it if the setState checkbox is deleted. The checkbox doesn't work.
bool _checkbox = false;
Checkbox(
value: _checkbox,
onChanged: (value) {
setState(() {
_checkbox = !_checkbox;
});
},
);
How can this problem be solved without deleting the data from the fields?
Thank you
CodePudding user response:
wrap in StatefulBuilder to reload only the checkbox
