Fixed report rendering in web

This commit is contained in:
2026-05-14 22:08:15 +08:00
parent e9d1af867a
commit 4b9b0c7a20
+1 -5
View File
@@ -1,4 +1,3 @@
import 'dart:isolate';
import 'dart:typed_data'; import 'dart:typed_data';
import 'dart:ui' as ui; import 'dart:ui' as ui;
@@ -72,8 +71,7 @@ class ReportPdfExport {
final generated = AppTime.formatDate(AppTime.now()); final generated = AppTime.formatDate(AppTime.now());
final dateLabel = dateRange.label; final dateLabel = dateRange.label;
// ── Build the PDF on a background isolate so it doesn't freeze the UI ── // ── Build the PDF on the main thread (dart:isolate is not supported on web) ──
return Isolate.run(() {
return _buildPdfBytes( return _buildPdfBytes(
chartImages: chartImages, chartImages: chartImages,
dateRangeText: dateRangeText, dateRangeText: dateRangeText,
@@ -83,11 +81,9 @@ class ReportPdfExport {
boldFontData: boldFontData.buffer.asUint8List(), boldFontData: boldFontData.buffer.asUint8List(),
logoBytes: logoBytes, logoBytes: logoBytes,
); );
});
} }
/// Pure function that assembles the PDF document from raw data. /// Pure function that assembles the PDF document from raw data.
/// Designed to run inside [Isolate.run].
static Future<Uint8List> _buildPdfBytes({ static Future<Uint8List> _buildPdfBytes({
required Map<String, Uint8List> chartImages, required Map<String, Uint8List> chartImages,
required String dateRangeText, required String dateRangeText,