WidgetKit And Picture rotation

I'm developing a widget with WidgetKit, and I'm having a problem: I need to click on an image, and when I click it triggers a network request, the image automatically rotates clockwise, and when the network ends, the image automatically stops rotating. How to do that?

My current idea is to click on the image and await the call to the network request. Should Toggle be used for the control corresponding to the picture? Because Toggle has two states. Then there is how to do image rotation, did not find support API.

Surely you can just use a Bool?

Set it to false initially, then flip it to true when the image is tapped. Then, the image rotation should kick in if the Bool == true.

Once your network call is finished, that should set the Bool to false and the image rotation should stop.

WidgetKit And Picture rotation
 
 
Q