Fixed report rendering in web
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
@@ -72,22 +71,19 @@ class ReportPdfExport {
|
||||
final generated = AppTime.formatDate(AppTime.now());
|
||||
final dateLabel = dateRange.label;
|
||||
|
||||
// ── Build the PDF on a background isolate so it doesn't freeze the UI ──
|
||||
return Isolate.run(() {
|
||||
return _buildPdfBytes(
|
||||
chartImages: chartImages,
|
||||
dateRangeText: dateRangeText,
|
||||
dateLabel: dateLabel,
|
||||
generated: generated,
|
||||
regularFontData: regularFontData.buffer.asUint8List(),
|
||||
boldFontData: boldFontData.buffer.asUint8List(),
|
||||
logoBytes: logoBytes,
|
||||
);
|
||||
});
|
||||
// ── Build the PDF on the main thread (dart:isolate is not supported on web) ──
|
||||
return _buildPdfBytes(
|
||||
chartImages: chartImages,
|
||||
dateRangeText: dateRangeText,
|
||||
dateLabel: dateLabel,
|
||||
generated: generated,
|
||||
regularFontData: regularFontData.buffer.asUint8List(),
|
||||
boldFontData: boldFontData.buffer.asUint8List(),
|
||||
logoBytes: logoBytes,
|
||||
);
|
||||
}
|
||||
|
||||
/// Pure function that assembles the PDF document from raw data.
|
||||
/// Designed to run inside [Isolate.run].
|
||||
static Future<Uint8List> _buildPdfBytes({
|
||||
required Map<String, Uint8List> chartImages,
|
||||
required String dateRangeText,
|
||||
|
||||
Reference in New Issue
Block a user