kevlatus / flutter_fortune_wheel

Visualize random selections with Flutter widgets like the wheel of fortune.
https://kevlatus.github.io/flutter_fortune_wheel
MIT License
109 stars 84 forks source link

FlutterError (setState() or markNeedsBuild() called during build when calling setState in onFocusItemChanged #114

Closed nelci592 closed 10 months ago

nelci592 commented 1 year ago

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.

stale[bot] commented 10 months ago

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.

winter-tech commented 8 months ago

I also encountered this problem. I wanted to display the results on the turntable, but the results would keep scrolling, but an error occurred.