animationOffset method

void animationOffset(
  1. double offset
)

update progress use animation

Implementation

void animationOffset(double offset) {
  disposeLine();
  _lineController = AnimationController(
    duration: Duration(milliseconds: 300),
    vsync: this,
  );
  var animate = Tween<double>(
    begin: lyricPaint.lyricOffset,
    end: offset,
  ).chain(CurveTween(curve: Curves.easeInOut)).animate(_lineController!)
    ..addStatusListener((status) {
      if (status == AnimationStatus.completed) {
        disposeLine();
      }
    });
  animate
    ..addListener(() {
      var value = animate.value;
      lyricPaint.lyricOffset = value.clamp(lyricPaint.maxOffset, 0);
    });
  _lineController?.forward();
}