Created
November 4, 2022 16:15
-
-
Save leighajarett/4b9cfedfe9ca09baeb83456fdf7cbe32 to your computer and use it in GitHub Desktop.
Flutter Simple Animation Example
This file contains hidden or 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'; | |
| import 'package:flutter/cupertino.dart'; | |
| void main() => runApp(MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return CupertinoApp( | |
| home: MyHomePage(), | |
| ); | |
| } | |
| } | |
| class MyHomePage extends StatefulWidget { | |
| const MyHomePage({super.key}); | |
| @override | |
| State<MyHomePage> createState() => _MyHomePageState(); | |
| } | |
| class _MyHomePageState extends State<MyHomePage> { | |
| double turns = 0; | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| body: Center( | |
| child: AnimatedRotation( | |
| duration: const Duration(seconds:1), | |
| turns: turns, | |
| curve: Curves.easeIn, | |
| child: TextButton( | |
| onPressed: () { | |
| setState(() { | |
| turns += .125; | |
| }); | |
| }, child: Text('Tap me!')), | |
| ) | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment