0

I am learning Flutter and trying to make advanced todo application. I want to sync todos with a cloud using aws amplify. The problem is that I need the sync to work not only from isolate of main app but also from isolate spawned by WorkManager.

This is where the problems start. I call Amplify.configure() both from main isolate and from background isolate. Since amplify plugin have native part it leads to an error. Gpt4 explained to me that native part is not actually isolated. That means that I need somehow synchronize work between isolates.

The best way I see for now is to move all work with amplify to background isolate. But, again, as I understand, WorkManger can spawn multiple isolates. And again I will need to sync between them. I could try to implement some kind of critical section plugin which uses the fact that native part of plugins is in fact singleton. This will allow me to put Amplify.configure() into critical section making sure that it is called only once. But... where is guarantee that other amplify calls do not need to be called only once? It looks that the whole amplify plugin should be a singleton across all isolates.

I am totally ambushed by such a crucial omission in the Flutter framework. I would greatly appreciate any suggestions or solutions. Thank you.

alehro
  • 2,198
  • 2
  • 25
  • 41

0 Answers0