Created
April 20, 2020 20:59
-
-
Save rayliverified/c0450ca427127acfb710a31c99761f1a to your computer and use it in GitHub Desktop.
Flutter.dev Example Spinning Flutter
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