Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work in isolate #4

Open
nathnaeld opened this issue Nov 18, 2022 · 2 comments
Open

Does not work in isolate #4

nathnaeld opened this issue Nov 18, 2022 · 2 comments

Comments

@nathnaeld
Copy link

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)

@yekeskin
Copy link
Owner

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.

@ozexpert
Copy link

ozexpert commented Feb 8, 2023

use flutter_isolate, you can use all packages in isolate.

@lucascardo12 lucascardo12 mentioned this issue Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants