PDF Receipt Service
services/pdf_receipt_service.dart
Overview
Generates a PDF receipt from an Order using the `pdf` package — order summary, line items, totals, addresses, optional seller block. Saves to temp + offers share/print via the platform sheet.
User Flow
- Service is instantiated per call (no provider).
- buildPdf(order) composes a multi-page document with pw.Document().
- savePdf writes to a temp file via path_provider; sharePdf forwards to Share.shareXFiles.
Cases & Edge Cases
- Long item lists wrap across pages — pageBreak is automatic via the pdf package, no manual splitting.
- RTL languages render through the default font — Arabic shaping is approximate, fine for printable receipts but not for layout-perfect typography.
- Service does not embed images today — seller photo URLs render as text-only fields.
Code References
- lib/src/features/shared/orders/services/pdf_receipt_service.dart
- lib/src/features/shared/orders/views/receipt_screen.dart
API Calls
Empty — fill this in later. Open the manifest and add content here.
Notes
Receipt regeneration must be idempotent — sharing the same order twice should produce byte-identical PDFs (modulo timestamps). No HTTP contract — operates purely on the in-memory Order entity. File output contracts: • savePdf(order) → File at <appCache>/receipt_<orderId>.pdf — screen: lib/src/features/shared/orders/views/receipt_screen.dart • sharePdf(file) → Share.shareXFiles([file]) (platform share sheet) — screen: lib/src/features/shared/orders/views/receipt_screen.dart