1.flutter动画效果
点击后动画
2.源代码
import 'package:flutter/material.dart'; void main() async { runApp( MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: MyApp(), ), ), ); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { AnimationController controller; Animation<double> animation; @override void initState() { super.initState(); controller = AnimationController( duration: Duration(seconds: 1), vsync: this, ); animation = CurvedAnimation( parent: controller, curve: Curves.easeInOutCubic, ).drive(Tween(begin: 0, end: 2)); } @override void dispose() { controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return GestureDetector( onTap: () { controller ..reset() ..forward(); }, child: RotationTransition( turns: animation, child: Stack( children: [ Positioned.fill( child: FlutterLogo(), ), Center( child: Text( '请,点击我!', style: TextStyle( fontSize: 60.0, fontWeight: FontWeight.bold, ), ), ), ], ), ), ); } }
3.运行效果如上