-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding new tweens in callback functions is not allowed? #9
Comments
Usually, how I have handled this is invoking either Timeline.createSequence() or Tween.to to create a totally new tween, have never seen an issue with it. Are you trying to add tweens to an already existing timeline? |
No. Do you add new tweens in another tween's callback function? |
I made a simple reproduction by your simple_tween.dart example Tween.to(pos, VectorAccessor.XY, 1)
..delay = 0.3
..targetValues = [x, y]
..start(_tweenManager);
to Tween.to(pos, VectorAccessor.XY, 1)
..delay = 0.3
..targetValues = [x, y]
..setCallback((int type, BaseTween source) {
Tween.to(pos, VectorAccessor.XY, 2)
..delay = 0.3
..targetValues = [x, y]
..start(_tweenManager);
})
..start(_tweenManager);
And you will get the error: Exception: Concurrent modification during iteration: Instance(length:2) of '_GrowableList'. |
will look into it as soon as I can |
fixed. Avoided applying the suggested fix to avoid allocating more lists into memory. This will be up for for next version |
I try to add some extra tweens in a callback function (i.e., when a tween completed).
However, since the other updating tweens occupy the _objects list in a forEach function, modifying the _object is not allowed.
Maybe you can add a new list (for those toBeAddedTweens), and pull the new tweens into _objects in the right timing?
The text was updated successfully, but these errors were encountered: