I want to animate my widget in a curve between the two offsets. My current code moves them in a straight line.
animation=MyTween(begin: startOffset,end: endOffset).animate(
CurvedAnimation(
parent: animationController,
curve: Curves.easeIn,
),);
My widget:-
AnimatedBuilder(
animation: animation,
child: Container(height:100,width:100, color: Colors.blue),
builder: (context,child){
return Transform.translate(
offset: animation.value,
child: child,
);
},
)
My custom tween:-
class MyTween extends Tween<Offset>{
@override
Offset lerp(double t) {
final p = Offset.lerp(begin, end, t)!;
return Offset(p.dx, p.dy + 100 * sin(2 * pi * t));
}
}