diff --git a/pdf/lib/src/pdf/document.dart b/pdf/lib/src/pdf/document.dart index 6c8a984c..a8ec75fc 100644 --- a/pdf/lib/src/pdf/document.dart +++ b/pdf/lib/src/pdf/document.dart @@ -16,6 +16,8 @@ import 'dart:math' as math; import 'dart:typed_data'; +import 'dart:isolate'; + import 'package:crypto/crypto.dart'; @@ -255,7 +257,14 @@ class PdfDocument { if (prev != null) { os.putBytes(prev!.bytes); } - await _write(os); + await _write(os); return os.output(); } + + /// [isolatedSave] this method is to isolate save in another thread to solve freezing app + Future isolatedSave() async { + if(kIsWeb) return await save(); + return Isolate.run(() async=>await save()); + + } }