How Flutter renders the widgets has been described in detail here. It will compare the new with the old widget. Therefore, Flutter usually knows how to re-render the UI in most cases.
In a nested object structure, all parent widgets inevitably change when you change the child, so they seem to be rendered new.
This leads to unattractive visual effects for the user of the app.
Is there a way to re-render only the widget in which SetState () was called?
I tried kinds of this.setState (() {}). I have swapped out the widgets in a stateless class.
Unfortunately, both approaches do not solve the problem.
Widget _createCheckbox(int dataArrayPosition, int elementCurrentPosition, int inputCurrentPosition) { Input inputElement = contextData.data[dataArrayPosition].element[elementCurrentPosition].input[inputCurrentPosition];
return Column(
children: <Widget>[
Row(
children: <Widget>[
Checkbox(
value: inputElement.checkBoxValue,
onChanged: (bool newValue) {
setState(() {
contextData.data[dataArrayPosition].element[elementCurrentPosition].input[inputCurrentPosition].checkBoxValue = newValue;
});
}),
Text(inputElement.labelForValue),
],
),
],
);
}
Does anyone know a way to re - render only the 'affected' widget in this example when onChanged was called?