Skip to content

Instantly share code, notes, and snippets.

@leighajarett
Created November 4, 2022 16:15
Show Gist options
  • Select an option

  • Save leighajarett/4b9cfedfe9ca09baeb83456fdf7cbe32 to your computer and use it in GitHub Desktop.

Select an option

Save leighajarett/4b9cfedfe9ca09baeb83456fdf7cbe32 to your computer and use it in GitHub Desktop.
Flutter Simple Animation Example
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