How do i let the same animation play on different places at the same time. For the moment whenever i tap the screen an animation start playing at that place for 3 seconds but if i press again on an other place the animation jumps to that place, but i would want it to let the old one finish. So that if you press five times there should be five animations on the screen unlike now when it only plays one at the time.
Here is my code.
class HomePage extends StatefulWidget{
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
double posx = -100.0;
double posy = -100.0;
void onLongPressMoveUpdate(BuildContext context, LongPressMoveUpdateDetails details)
{
final RenderBox box = context.findRenderObject();
final Offset localOffset = box.globalToLocal(details.globalPosition);
var tempName = "tryck";
setState(() {
_tryckanimation = tempName;
posx = localOffset.dx;
posy = localOffset.dy;
});
}
void onTapDown(BuildContext context, TapDownDetails details)
{
final RenderBox box = context.findRenderObject();
final Offset localOffset = box.globalToLocal(details.globalPosition);
var tempName = "tryck";
setState(() {
_tryckanimation = tempName;
posx = localOffset.dx;
posy = localOffset.dy;
});
}
void onTapUp(BuildContext context, TapUpDetails details)
{
final RenderBox box = context.findRenderObject();
final Offset localOffset = box.globalToLocal(details.globalPosition);
var tempName = "tryck";
Future.delayed(const Duration(milliseconds: 3000), () {
setState(() {
setState(() {
_tryckanimation = tempName;
posx = -100.0;
posy = -100.0;
});
});
});
}
new GestureDetector(
onTapDown: (TapDownDetails details) => onTapDown(context, details),
onTapUp: (TapUpDetails details) => onTapUp(context, details),
onLongPressMoveUpdate: (LongPressMoveUpdateDetails details) => onLongPressMoveUpdate(context, details),
child: new Stack(fit: StackFit.expand, children: <Widget>[
new Container(color: Colors.transparent,
),
new Positioned(
height: 100.0,
width: 100.0,
child: FlareActor(
"assets/images/tryck2.flr",
animation: _tryckanimation
),
left: posx -50.0,
top: posy- 50.0,
),