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

Update document.dart #1623

Closed
wants to merge 3 commits into from
Closed

Update document.dart #1623

wants to merge 3 commits into from

Conversation

Gemy-Dev
Copy link
Contributor

@Gemy-Dev Gemy-Dev commented Mar 5, 2024

isolate it in another thread because it's freeze app

Gemy-Dev added 2 commits March 5, 2024 02:11
isolate it in another thread because it's freeze app
add Isolate.run method to solve freezing app
Copy link
Contributor Author

@Gemy-Dev Gemy-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isolate save in another thread to solve freezing app

@DavBfr
Copy link
Owner

DavBfr commented Mar 7, 2024

This library is compatible with Dart only (no Flutter) and Web.
This implementation won't work when built to JavaScript.

@Gemy-Dev
Copy link
Contributor Author

Gemy-Dev commented Mar 7, 2024

This library is compatible with Dart only (no Flutter) and Web.
This implementation won't work when built to JavaScript.

Yes I made some changes to replace compute method Thats only work on flutter to Isolate.run() it's run on dart
here is the old
/// Generate the PDF document as a memory file
// Future save() async {
// final os = PdfStream();
// if (prev != null) {
// os.putBytes(prev!.bytes);
// }
// // to isolate it because it frease app
// await compute(await _write,os);

// // await _write(os);
// return os.output();
// }

and there is the new

Future _save() async {
final os = PdfStream();
if (prev != null) {
os.putBytes(prev!.bytes);
}
await _write(os);
return os.output();
}
// isolate save in another thread to solve freezing app
Future save() async {
return
await Isolate.run(()async=> await _save());

}

We added isolatedSave method to solve freezing app 
Note. isolate not work on web
@Gemy-Dev
Copy link
Contributor Author

using IsolateSave() method is solve freezing when save pdf file but it's not work for web

@Gemy-Dev
Copy link
Contributor Author

using IsolatedSave() method is solve freezing when save pdf file but it's not work for web

@DavBfr
Copy link
Owner

DavBfr commented Mar 11, 2024

OK, I'll make a version of that

@DavBfr DavBfr closed this Mar 11, 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

Successfully merging this pull request may close these issues.

2 participants