AnimatedRotationModifier class
Animated version of Transform.rotate which automatically transitions the child's rotation over a given duration whenever the given rotation changes.
{@tool snippet}
This code defines a widget that uses AnimatedRotation to rotate a FlutterLogo gradually by an eighth of a turn (45 degrees) with each press of the button.
class LogoRotate extends StatefulWidget {
const LogoRotate({super.key});
@override
State<LogoRotate> createState() => LogoRotateState();
}
class LogoRotateState extends State<LogoRotate> {
double turns = 0.0;
void _changeRotation() {
setState(() => turns += 1.0 / 8.0);
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: _changeRotation,
child: const Text('Rotate Logo'),
),
Padding(
padding: const EdgeInsets.all(50),
child: AnimatedRotation(
turns: turns,
duration: const Duration(seconds: 1),
child: const FlutterLogo(),
),
),
],
);
}
}
{@end-tool}
See also:
- AnimatedScale, for animating the scale of a child.
- RotationTransition, an explicitly animated version of this widget, where an Animation is provided by the caller instead of being built in.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- SingleChildStatelessModifier
- SingleChildImplicitlyAnimatedModifier
- AnimatedRotationModifier
- Available extensions
Constructors
- AnimatedRotationModifier({Key? key, Widget? child, Curve curve = Curves.linear, required Duration duration, VoidCallback? onEnd, Key? modifierKey, required double turns, Alignment alignment = Alignment.center, FilterQuality? filterQuality})
-
Creates a widget that animates its rotation implicitly.
const
Properties
- alignment → Alignment
-
The alignment of the origin of the coordinate system in which the rotation
takes place, relative to the size of the box.
final
- curve → Curve
-
The curve to apply when animating the parameters of this container.
finalinherited
- duration → Duration
-
The duration over which to animate the parameters of this container.
finalinherited
- filterQuality → FilterQuality?
-
The filter quality with which to apply the transform as a bitmap operation.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- modifierKey → Key?
-
The actual key of the widget, which Modifier wrapped
finalinherited
- onEnd → VoidCallback?
-
Called every time an animation completes.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- turns → double
-
The animation that controls the rotation of the child.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
buildWithChild(
BuildContext context, Widget? child) → Widget -
A build method that receives an extra
child
parameter.override -
createElement(
) → SingleChildStatelessElement -
Create a SingleChildStatelessElement
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited