Does not work in isolate
I was trying to encode an image to AVIF in isolate using compute but it shows the following error:
Unhandled Exception: LateInitializationError: Field 'api' has not been initialized.
FlutterAvifPlatform.api (package:flutter_avif_platform_interface/flutter_avif_platform_interface.dart)
encodeAvif (package:flutter_avif/src/avif_encoder.dart:16:53)
Hi, error you are getting can be solved by calling DartPluginRegistrant.ensureInitialized() before using the plugin. But after that you will encounter other errors. The real issue here is that encodeAvif function uses dart:ui package to read images as rgba and dart:ui does not work in isolates. So you cannot use encodeAvif in an isolate.
use flutter_isolate, you can use all packages in isolate.