How do I rotate something 15 degrees in Flutter?

In mobile apps, I think it's kind of rare to have things start out rotated 15 degrees and just stay there forever. So that may be why Flutter's support for rotation is better if you're planning to adjust the rotation over time.

It feels like overkill, but a RotationTransition with an AlwaysStoppedAnimation would accomplish exactly what you want.

screenshot

new RotationTransition(
  turns: new AlwaysStoppedAnimation(15 / 360),
  child: new Text("Lorem ipsum"),
)

If you want to rotate something 90, 180, or 270 degrees, you can use a RotatedBox.

screenshot

new RotatedBox(
  quarterTurns: 1,
  child: new Text("Lorem ipsum")
)

You can use Transform.rotate to rotate your widget. I used Text and rotated it with 45˚ (π/4)

Example:

import 'dart:math' as math;

Transform.rotate(
  angle: -math.pi / 4,
  child: Text('Text'),
)

enter image description here

Tags:

Dart

Flutter