DEV Community

Melvin S
Melvin S

Posted on

Flutter: How to rotate an Icon?

Transform widget to the rescue

A Transform widget “transforms” (i.e. changes the shape, size, position and orientation) its child widget before painting it.

Transform.rotate

Transform.rotate rotates a child by an angle in radians not degrees. So, to rotate by 90 degrees, you need to multiply 90 x π/180 to get the value in radians.

Code:

Don't forget to import 'dart:math' to use pi. :) More info on Transform widget here:

Top comments (0)