Search code examples
androidflutterdartembeddingisolate

How to share common code between multiple flutter engines?


I have a flutter added into my android host project. I am currently having multiple flutter engines. But there is no sharing of code between these engines. Therefore method-channel calls are happening multiple times. I have a single entry point for all the engines. I tried using singleton in my flutter code, but that is also executed multiple times. What would be a good solution to this. I read 'IsolateGroup' can be used but I haven't implemented it yet so I don't have a reference.


Solution

  • I found 2 solutions on this :

    1. Isar DB - this can act as a common database layer, engines can read and write and share common data.
    2. SendPort - using this we can pass data with other engines