You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
import 'package:flutter/material.dart';
|
|
|
|
import 'live_animate_Icon.dart';
|
|
|
|
class LiveAnimate extends StatefulWidget {
|
|
final double size;
|
|
final double strokeWidth;
|
|
final int place;
|
|
final Duration delay;
|
|
final Duration duration;
|
|
|
|
const LiveAnimate(
|
|
{Key key,
|
|
@required this.size,
|
|
@required this.strokeWidth,
|
|
@required this.place,
|
|
@required this.delay,
|
|
@required this.duration})
|
|
: super(key: key);
|
|
|
|
@override
|
|
_LiveAnimateState createState() => _LiveAnimateState();
|
|
}
|
|
|
|
class _LiveAnimateState extends State<LiveAnimate>
|
|
with TickerProviderStateMixin {
|
|
AnimationController _controller;
|
|
Animation _animation;
|
|
|
|
@override
|
|
void initState() {
|
|
_controller = AnimationController(vsync: this, duration: widget.duration);
|
|
|
|
_animation = CurveTween(curve: Curves.easeInOut).animate(_controller);
|
|
Future.delayed(widget.delay, () async {
|
|
try {
|
|
await _controller.forward().orCancel;
|
|
await _controller.reverse().orCancel;
|
|
await _controller.repeat(reverse: true).orCancel;
|
|
} on TickerCanceled {
|
|
print('animate stopped ${widget.place}');
|
|
}
|
|
});
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AnimatedBuilder(
|
|
animation: _animation,
|
|
builder: (context, child) {
|
|
return CustomPaint(
|
|
painter: LiveAnimateIcon(
|
|
_animation.value, widget.strokeWidth, widget.place),
|
|
size: Size(widget.size / 3, widget.size * 0.5),
|
|
);
|
|
});
|
|
}
|
|
}
|