Created
October 30, 2019 07:03
-
-
Save mewben/f84ba2e3037f0af202d3aa2df96aa6dc to your computer and use it in GitHub Desktop.
Flutter: Rotate Icon by 90 degrees
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:math'; | |
class RotatedIcon extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Transform.rotate( | |
angle: 90 * pi/180, | |
child: Icon(Icons.flight), | |
); | |
} | |
} |
You can also use the RotationTransition widget.No need to import math and you only divide the angle by 360.
RotationTransition(
turns: AlwaysStoppedAnimation(90 / 360),
child: Icon(Icons.arrow_drop_down),
),
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great! What's the deal with such angle? What's the unit here in Flutter? I was expecting
90
to just work, but obviously it didn't and I ended up here 🙂And this is the widget I ended up with: