rotate IconButton flutter flutter rotate animation icon on press

The solution for “rotate IconButton flutter flutter rotate animation icon on press” can be found here. The following code will assist you in solving the problem.

import ‘dart:math’ as math;

Transform.rotate(
angle: 180 * math.pi / 180,
child: IconButton(
icon: Icon(
Icons.play,
color: Colors.white,
),
onPressed: null,
),
),@override
void initState() {
super.initState();

_controller = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
upperBound: 0.5,
);
}

@override
void dispose() {
super.dispose();
_controller.dispose();
}

RotationTransition(
turns: Tween(begin: 0.0, end: 0.5).animate(_controller),
child: IconButton(
icon: Icon(Icons.expand_less),
onPressed: () {
setState(() {
if (_expanded) {
_controller..reverse(from: 0.5);
} else {
_controller..forward(from: 0.0);
}
_expanded = !_expanded;
});
},
),
)

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in