Closed MasterNeuromancer closed 2 years ago
I had the same issue and found two solutions.. however, the second one destroyed the drag of a DraggableBottomSheet I have in my app.. So i stuck to the first one
1 - just wrap the onChanged function with WidgetsBinding as such :
WidgetsBinding.instance.addPostFrameCallback((_){
// Add Your Code here.
});
2- the other method is to use SchedulerBinding :
SchedulerBinding.instance.addPostFrameCallback((_) {
// add your code here.
});
Incase you'd like to see where i found those solutions : https://stackoverflow.com/questions/47592301/setstate-or-markneedsbuild-called-during-build
Thanks @Bader-Al , I will look into that!
I just made a PR to solve this issue.
Thank you so much
I was having the same problem what i did was add an if condition inside the _determine() function (as it is called during initState)
if (changeState) widget.onChanged(turnState);
when the widget loads, the state is false, and therefore unintended calls are being made on the app. Is there a way to isolate the on tap function only. I only want the calls to be made when a user taps the widget, not on load. Thank you.