Gamal AbdelNasser
Committed by David PHAM-VAN

Save in an isolate when available

# Changelog
## 3.11.0
- Save in an isolate when available
## 3.10.8
- Add Flutter's Logical Pixel constant
... ...
... ... @@ -251,11 +251,13 @@ class PdfDocument {
/// Generate the PDF document as a memory file
Future<Uint8List> save() async {
final os = PdfStream();
if (prev != null) {
os.putBytes(prev!.bytes);
}
await _write(os);
return os.output();
return pdfCompute(() async {
final os = PdfStream();
if (prev != null) {
os.putBytes(prev!.bytes);
}
await _write(os);
return os.output();
});
}
}
... ...
... ... @@ -20,3 +20,10 @@ import '../format/object_base.dart';
/// Zip compression function
DeflateCallback defaultDeflate = const ZLibEncoder().encode;
/// The dart:html implementation of [pdfCompute].
@pragma('dart2js:tryInline')
Future<R> pdfCompute<R>(Future<R> Function() computation) async {
await null;
return computation();
}
... ...
... ... @@ -15,8 +15,14 @@
*/
import 'dart:io';
import 'dart:isolate';
import '../format/object_base.dart';
/// Zip compression function
DeflateCallback defaultDeflate = zlib.encode;
/// The dart:io implementation of [pdfCompute].
@pragma('vm:prefer-inline')
Future<R> pdfCompute<R>(Future<R> Function() computation) async =>
Isolate.run<R>(computation, debugName: 'dart_pdf');
... ...
... ... @@ -15,7 +15,7 @@ topics:
version: 3.10.8
environment:
sdk: ">=2.18.0 <4.0.0"
sdk: ">=2.19.0 <4.0.0"
dependencies:
archive: ^3.1.0
... ...