This issue is hard to reproduce but it happens reliably during a hot restart.
Pending items:
[x] I need to do more testing on it but it seems to work well.
[x] Also, changes to the Flutter Engine in beta channel (https://github.com/flutter/flutter/issues/124829) would make this fix more straight forward. I'm going to try using a preprocessor directive so the code can have a fix for flutter stable and another one for flutter beta.
[x] See if the error is happening on windows or linux.
This PR fixes #121.
This issue is hard to reproduce but it happens reliably during a hot restart.
Pending items: