FlutterError (setState() or markNeedsBuild() called during build when calling setState in onFocusItemChanged
nelci592 opened this issue · 2 comments
When using setState in onFocusItemChanged. For example:
onFocusItemChanged: (int index) {
setState(() {
_isLifted = !_isLifted;
});
},
I get the following error:
FlutterError (setState() or markNeedsBuild() called during build.
This FortuneWheelView widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I also encountered this problem. I wanted to display the results on the turntable, but the results would keep scrolling, but an error occurred.