Closed DonAlex1897 closed 3 years ago
You can't. At least the default one uses sqflite which uses methodchannels and these are only supported on the main isolate. See: https://github.com/flutter/flutter/issues/16846#issuecomment-383752606
What are you trying to do in the compute method?
I need to download a list of audio files from the server. When the first file is downloaded, it should be played. So I have to download the other audio files of the list in the background. Downloading process of other audio files is being done in the compute method.
I/O and http calls are always done asynchronously on their own isolate. So you shouldn't need compute for what you are trying to do. Did you try without compute? Could you give me an example that's not working?
Yes. You are right. I just realized that I had used the compute method because of a "synchronous decryption" method. Now that I am using my own built encryption method, I do not need the compute anymore. Thanks for your attention.
Do we have another cache managers (or settings) which are accessible from other isolates.
When I am trying to use DefaultCacheManager().getSingleFile(fileAddress), this error occurs:
I tried adding
WidgetsFlutterBinding.ensureInitialized()
to the first line of the main method, as flutter proposed. But it did not resolve my problem.