Skip to content

Instantly share code, notes, and snippets.

@timnew
Created November 17, 2020 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timnew/ba6b4930d07c7cbd6db7d237e449e051 to your computer and use it in GitHub Desktop.
Save timnew/ba6b4930d07c7cbd6db7d237e449e051 to your computer and use it in GitHub Desktop.
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