Flutter - change variables inside or outside setState?
Already been posted here this question.
It's a convetion, it doesn't matter, but, it's good pratica to wrap all the changes inside the setState function. But the results will be the same in both cases.
I've read somewhere that an empty setState is a "code smell", because the body of the callback should indicate the reason for the setState.
According to the flutter docs, it is stated that:
Generally it is recommended that the setState method only be used to wrap the actual changes to the state, not any computation that might be associated with the change.
Mainly I think that it is for readability purposes, i.e, you need to put in the body of setState
what is changing in the new build of the widget, without mixing that with your computations as the first method in your question does.