-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathactive_beacon.dart
More file actions
49 lines (45 loc) · 1.26 KB
/
active_beacon.dart
File metadata and controls
49 lines (45 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import 'package:flutter/material.dart';
class BlinkIcon extends StatefulWidget {
@override
_BlinkIconState createState() => _BlinkIconState();
}
class _BlinkIconState extends State<BlinkIcon> with TickerProviderStateMixin {
AnimationController? _controller;
Animation<Color?>? _colorAnimation;
@override
void initState() {
_controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 700));
_colorAnimation = ColorTween(
begin: Color(0xFF30c295), end: Colors.transparent)
.animate(CurvedAnimation(parent: _controller!, curve: Curves.linear));
_controller!.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_controller!.reverse();
} else if (status == AnimationStatus.dismissed) {
_controller!.forward();
}
setState(() {});
});
_controller!.forward();
super.initState();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller!,
builder: (context, child) {
return Icon(
Icons.circle,
size: 10,
color: _colorAnimation!.value,
);
},
);
}
@override
void dispose() {
_controller!.dispose();
super.dispose();
}
}