Untitled
unknown
dart
2 years ago
1.5 kB
5
Indexable
class _MyHomePageState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; int counter = 0; void _onPressed() { setState(() { counter++; }); _controller.forward(from: 0.0); } @override void initState() { _controller = AnimationController( vsync: this, duration: const Duration(milliseconds: 600)); super.initState(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: FloatingActionButton( onPressed: _onPressed, splashColor: Colors.lightBlue.shade200, backgroundColor: Colors.blue, child: Icon( Icons.flip, color: Colors.white, ), ), body: AnimatedBuilder( animation: _controller, builder: (_, child) => Transform( alignment: Alignment.center, transform: Matrix4.identity() ..setEntry(3, 2, 0.001) ..rotateY(360 * _controller.value * (pi / 180.0)), child: LogoWidget( counter: counter, ), ), ), ); } } class LogoWidget extends StatelessWidget { final int counter; const LogoWidget({Key? key, required this.counter}) : super(key: key); @override Widget build(BuildContext context) { print(' Rebuilding Widget'); return Center( child: SizedBox(height: 100, width: 100, child: FlutterLogo()), ); } }
Editor is loading...