Created
November 17, 2020 03:51
-
-
Save timnew/ba6b4930d07c7cbd6db7d237e449e051 to your computer and use it in GitHub Desktop.
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'; | |
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( | |
'Click me!', | |
style: TextStyle( | |
fontSize: 60.0, | |
fontWeight: FontWeight.bold, | |
), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment