David PHAM-VAN

Fix example application

# 2.0.2
* Fix example application
# 2.0.1
* Fix Replace FlutterErrorDetails to be compatible with Dart 2.3.0
... ...
... ... @@ -106,7 +106,7 @@ class Category extends StatelessWidget {
}
}
Future<PdfDocument> generateDocument(PdfPageFormat format) async {
Future<Document> generateDocument(PdfPageFormat format) async {
final PdfDoc pdf = PdfDoc(title: 'My Résumé', author: 'David PHAM-VAN');
final PdfImage profileImage = await pdfImageFromImageProvider(
... ... @@ -198,5 +198,5 @@ Future<PdfDocument> generateDocument(PdfPageFormat format) async {
])
]),
));
return pdf.document;
return pdf;
}
... ...
... ... @@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pdf;
import 'package:printing/printing.dart';
import 'package:printing_example/document.dart';
... ... @@ -33,7 +34,7 @@ class MyAppState extends State<MyApp> {
Future<void> _sharePdf() async {
print('Share ...');
final PdfDocument pdf = await generateDocument(PdfPageFormat.a4);
final pdf.Document document = await generateDocument(PdfPageFormat.a4);
// Calculate the widget center for iPad sharing popup position
final RenderBox referenceBox =
... ... @@ -44,7 +45,8 @@ class MyAppState extends State<MyApp> {
referenceBox.localToGlobal(referenceBox.paintBounds.bottomRight);
final Rect bounds = Rect.fromPoints(topLeft, bottomRight);
Printing.sharePdf(document: pdf, filename: 'my-résumé.pdf', bounds: bounds);
await Printing.sharePdf(
bytes: document.save(), filename: 'my-résumé.pdf', bounds: bounds);
}
Future<void> _printScreen() async {
... ...
... ... @@ -3,13 +3,14 @@ import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:pdf/pdf.dart';
import 'package:pdf/widgets.dart' as pdf;
import 'package:printing_example/document.dart';
void main() {
testWidgets('Pdf Generate the document', (WidgetTester tester) async {
final PdfDocument pdf = await generateDocument(PdfPageFormat.a4);
final pdf.Document document = await generateDocument(PdfPageFormat.a4);
final File file = File('document.pdf');
file.writeAsBytesSync(pdf.save());
file.writeAsBytesSync(document.save());
});
}
... ...
... ... @@ -4,7 +4,7 @@ description: Plugin that allows Flutter apps to generate and print documents to
homepage: https://github.com/DavBfr/dart_pdf/tree/master/printing
repository: https://github.com/DavBfr/dart_pdf
issue_tracker: https://github.com/DavBfr/dart_pdf/issues
version: 2.0.1
version: 2.0.2
environment:
sdk: ">=2.1.0 <3.0.0"
... ...