Open rdcoder33 opened 2 years ago
For example file example >> lib >> animation_full_control.dart
Using SetState in initState cause the following error setState() or markNeedsBuild() called when widget tree was locked.
setState() or markNeedsBuild() called when widget tree was locked.
I have added a WidgetsBinding.instance.addPostFrameCallback wrapper to fix it. It's tested and work fine on all platforms.
WidgetsBinding.instance.addPostFrameCallback
@override void initState() { _controller = AnimationController(vsync: this); WidgetsBinding.instance.addPostFrameCallback((_) => setState(() { _controller .addListener(() { setState(() { // Rebuild the widget at each frame to update the "progress" label. }); }); })); super.initState(); }
For example file example >> lib >> animation_full_control.dart
Using SetState in initState cause the following error
setState() or markNeedsBuild() called when widget tree was locked.
I have added a
WidgetsBinding.instance.addPostFrameCallback
wrapper to fix it. It's tested and work fine on all platforms.