I would like to animate the icon of this ElevatedButton when pressed.
The idea was to make the icon spin for a few seconds after pressing this button.
Can anyone help me?
This is the code:
ElevatedButton.icon(
onPressed: () {},
icon: const Icon(Icons.sync),
label: const Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0),
child: Text("Sincronizza"),
)
),
2
Answers
I am not sure you could do that in
ElevatedButton.icon
but, you could achieve it usingElevatedButton
with some updates in the child.Example:
You can use AnimatedBuilder inside elevated button by passing as icon widget. Below I tried code when elevated button clicked the animation starts and will load until button is clicked again. you can control animated icon when to stop by making loader false and setstate it.
You can preview or play with code here