David PHAM-VAN

Fix flutter test target

class CustomData {
const CustomData({this.name = '[your name]'});
const CustomData({
this.name = '[your name]',
this.testing = false,
});
final String name;
final bool testing;
}
... ...
... ... @@ -27,8 +27,12 @@ Future<Uint8List> generateDocument(
PdfPageFormat format, CustomData data) async {
final doc = pw.Document(pageMode: PdfPageMode.outlines);
final font1 = await PdfGoogleFonts.openSansRegular();
final font2 = await PdfGoogleFonts.openSansBold();
final font1 = data.testing
? pw.Font.helvetica()
: await PdfGoogleFonts.openSansRegular();
final font2 = data.testing
? pw.Font.helveticaBold()
: await PdfGoogleFonts.openSansBold();
final shape = await rootBundle.loadString('assets/document.svg');
final swirls = await rootBundle.loadString('assets/swirls2.svg');
... ...
... ... @@ -7,7 +7,7 @@ import 'package:printing_demo/examples/document.dart';
void main() {
testWidgets('Pdf Generate the document', (WidgetTester tester) async {
const data = CustomData();
const data = CustomData(testing: true);
final doc = await generateDocument(PdfPageFormat.a4, data);
final file = File('document.pdf');
... ...
... ... @@ -24,5 +24,9 @@ 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');
Future<R> pdfCompute<R>(Future<R> Function() computation) async {
if (Platform.environment.containsKey('FLUTTER_TEST')) {
return computation();
}
return Isolate.run<R>(computation, debugName: 'dart_pdf');
}
... ...