mirror of
https://github.com/cupcakearmy/fight-of-the-mobiles.git
synced 2026-04-02 18:25:23 +00:00
code
This commit is contained in:
37
src/flutter/lib/Components/SyncIcon.dart
Normal file
37
src/flutter/lib/Components/SyncIcon.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/animation.dart';
|
||||
|
||||
class SyncIcon extends StatefulWidget {
|
||||
_SyncIcon createState() => _SyncIcon();
|
||||
}
|
||||
|
||||
class _SyncIcon extends State<SyncIcon> with SingleTickerProviderStateMixin {
|
||||
Animation<double> animation;
|
||||
AnimationController controller;
|
||||
|
||||
initState() {
|
||||
super.initState();
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 2000), vsync: this);
|
||||
animation = Tween(begin: 0.0, end: pi * 2).animate(controller);
|
||||
animation.addListener(() => setState(() {}));
|
||||
controller.repeat();
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Transform.rotate(
|
||||
angle: animation.value,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10.0),
|
||||
height: 32.0,
|
||||
width: 32.0,
|
||||
child: Image.asset('images/sync.png'),
|
||||
));
|
||||
}
|
||||
|
||||
dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user