Showing
4 changed files
with
19 additions
and
6 deletions
| @@ -27,8 +27,12 @@ Future<Uint8List> generateDocument( | @@ -27,8 +27,12 @@ Future<Uint8List> generateDocument( | ||
| 27 | PdfPageFormat format, CustomData data) async { | 27 | PdfPageFormat format, CustomData data) async { |
| 28 | final doc = pw.Document(pageMode: PdfPageMode.outlines); | 28 | final doc = pw.Document(pageMode: PdfPageMode.outlines); |
| 29 | 29 | ||
| 30 | - final font1 = await PdfGoogleFonts.openSansRegular(); | ||
| 31 | - final font2 = await PdfGoogleFonts.openSansBold(); | 30 | + final font1 = data.testing |
| 31 | + ? pw.Font.helvetica() | ||
| 32 | + : await PdfGoogleFonts.openSansRegular(); | ||
| 33 | + final font2 = data.testing | ||
| 34 | + ? pw.Font.helveticaBold() | ||
| 35 | + : await PdfGoogleFonts.openSansBold(); | ||
| 32 | final shape = await rootBundle.loadString('assets/document.svg'); | 36 | final shape = await rootBundle.loadString('assets/document.svg'); |
| 33 | final swirls = await rootBundle.loadString('assets/swirls2.svg'); | 37 | final swirls = await rootBundle.loadString('assets/swirls2.svg'); |
| 34 | 38 |
| @@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart'; | @@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart'; | ||
| 7 | 7 | ||
| 8 | void main() { | 8 | void main() { |
| 9 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { | 9 | testWidgets('Pdf Generate the document', (WidgetTester tester) async { |
| 10 | - const data = CustomData(); | 10 | + const data = CustomData(testing: true); |
| 11 | final doc = await generateDocument(PdfPageFormat.a4, data); | 11 | final doc = await generateDocument(PdfPageFormat.a4, data); |
| 12 | 12 | ||
| 13 | final file = File('document.pdf'); | 13 | final file = File('document.pdf'); |
| @@ -24,5 +24,9 @@ DeflateCallback defaultDeflate = zlib.encode; | @@ -24,5 +24,9 @@ DeflateCallback defaultDeflate = zlib.encode; | ||
| 24 | 24 | ||
| 25 | /// The dart:io implementation of [pdfCompute]. | 25 | /// The dart:io implementation of [pdfCompute]. |
| 26 | @pragma('vm:prefer-inline') | 26 | @pragma('vm:prefer-inline') |
| 27 | -Future<R> pdfCompute<R>(Future<R> Function() computation) async => | ||
| 28 | - Isolate.run<R>(computation, debugName: 'dart_pdf'); | 27 | +Future<R> pdfCompute<R>(Future<R> Function() computation) async { |
| 28 | + if (Platform.environment.containsKey('FLUTTER_TEST')) { | ||
| 29 | + return computation(); | ||
| 30 | + } | ||
| 31 | + return Isolate.run<R>(computation, debugName: 'dart_pdf'); | ||
| 32 | +} |
-
Please register or login to post a comment