I'm using better_player package for list of videos in my application. The package is providing the preCache method which cache the video. So just a quick question can i run this method in separate isolate so my UI thread work smoothly. Or isolates have some restrictions?
1 Answer
There is no restrictions from dart side to use plugins inside isolates, but there is caveat described in this question and answer to it: Flutter resize and compress image in Isolate throws UnimplementedError
TLDR; you can use flutter plugins in isolates, but you should use more low-level APIs for isolates there, since it's obligatory to initiate BackgroundIsolateBinaryMessenger first.
Good news is that you don't have to use isolates at all! Reason for this: this plugin delegates caching operations to platform implementations and these implementations handle I/O and asynchronous operations itself:
- WorkManager used on Android, source code
- URLSession used on iOS and it handles non-blocking download itself internally, source code
So, you can just use preCache
method in your code and not be worried about performance.