mikeperri / flutter_sequencer

A Flutter plugin for music sequencing.
Other
90 stars 38 forks source link

Crash when calling destroy() on Sequence #34

Open andreasmpet opened 2 years ago

andreasmpet commented 2 years ago

Hi!

I noticed that in Sequence's destroy() method you're iterating through a collection with forEach at the same time as you're modifying it. Not sure how this has worked before. Maybe some behavior of how iterating through the values of a map has changed recently.

void destroy() {
    _tracks.values.forEach((track) => deleteTrack(track));
    globalState.unregisterSequence(this);
}

deleteTrack now seems to be modifying the collection we are iterating through it. A simple solution is to copy the list of track to a list before iterating through it, or just using _tracks.values.toList().forEachinstead.