Skip to content

Commit

Permalink
Fix example application
Browse files Browse the repository at this point in the history
  • Loading branch information
DavBfr committed May 4, 2019
1 parent 59c8070 commit ea4b3de
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions printing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.0.2
* Fix example application

# 2.0.1
* Fix Replace FlutterErrorDetails to be compatible with Dart 2.3.0

Expand Down
4 changes: 2 additions & 2 deletions printing/example/lib/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -198,5 +198,5 @@ Future<PdfDocument> generateDocument(PdfPageFormat format) async {
])
]),
));
return pdf.document;
return pdf;
}
6 changes: 4 additions & 2 deletions printing/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 =
Expand All @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions printing/example/test/pdf_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
}
2 changes: 1 addition & 1 deletion printing/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ea4b3de

Please sign in to comment.