可容纳一个子组件,并使其进行旋转动画,需要提供动画器turns,拥有alignment属性。

相关组件

RotatedBox

RotationTransition基本使用

  1. <br />【child】 : 孩子组件 【Widget】<br />【turns】 : 是否消失 【Animation<double><br />![133.gif](https://cdn.nlark.com/yuque/0/2020/gif/326147/1589456500602-46a80f2d-b5a3-4f53-9713-988170d669d6.gif#align=left&display=inline&height=242&margin=%5Bobject%20Object%5D&name=133.gif&originHeight=242&originWidth=800&size=450752&status=done&style=none&width=800)
import 'package:flutter/material.dart';
class CustomRotationTransition extends StatefulWidget {
  @override
  _CustomRotationTransitionState createState() => _CustomRotationTransitionState();
}

class _CustomRotationTransitionState extends State<CustomRotationTransition> with SingleTickerProviderStateMixin{

  AnimationController _ctrl;

  @override
  void initState() {
     _ctrl= AnimationController(vsync: this,duration: Duration(seconds: 2));
     _ctrl.forward();
    super.initState();
  }
@override
  void dispose() {
    _ctrl.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

    return GestureDetector(
      onTap: () {
        setState(() {
          _ctrl.reset();
          _ctrl.forward();
        });
      },
      child: Container(
        color: Colors.grey.withAlpha(22),
        width: 100,
        height: 100,
        child: RotationTransition(
          turns: CurvedAnimation(parent: _ctrl, curve: Curves.linear),
          child: Icon(Icons.android,color: Colors.green,size: 60),
        ),
      ),
    );
  }
}