David PHAM-VAN

Fix readme

@@ -141,6 +141,23 @@ and refresh. @@ -141,6 +141,23 @@ and refresh.
141 141
142 Take a look at the [example tab](example) for a sample project. 142 Take a look at the [example tab](example) for a sample project.
143 143
  144 +Update the `_generatePdf` method with your design.
  145 +
  146 +```dart
  147 +Future<Uint8List> _generatePdf(PdfPageFormat format, String title) async {
  148 + final pdf = pw.Document();
  149 +
  150 + pdf.addPage(
  151 + pw.Page(
  152 + pageFormat: format,
  153 + build: (context) => pw.Placeholder(),
  154 + ),
  155 + );
  156 +
  157 + return pdf.save();
  158 + }
  159 +```
  160 +
144 This widget also features a debug switch at the bottom right to display the 161 This widget also features a debug switch at the bottom right to display the
145 drawing constraints used. This switch is available only on debug builds. 162 drawing constraints used. This switch is available only on debug builds.
146 163
@@ -148,6 +165,7 @@ Moving on to your production application, you can keep only the `_generatePdf` @@ -148,6 +165,7 @@ Moving on to your production application, you can keep only the `_generatePdf`
148 function and print the document using: 165 function and print the document using:
149 166
150 ```dart 167 ```dart
  168 +final title = 'Flutter Demo';
151 await Printing.layoutPdf(onLayout: (format) => _generatePdf(format, title)); 169 await Printing.layoutPdf(onLayout: (format) => _generatePdf(format, title));
152 ``` 170 ```
153 171
@@ -49,13 +49,12 @@ void buildFile(String src, String dest, bool flutter) { @@ -49,13 +49,12 @@ void buildFile(String src, String dest, bool flutter) {
49 final output = File(dest); 49 final output = File(dest);
50 final st = output.openWrite(); 50 final st = output.openWrite();
51 st.writeln('import \'dart:io\';'); 51 st.writeln('import \'dart:io\';');
  52 + st.writeln('import \'dart:typed_data\';');
52 if (flutter) { 53 if (flutter) {
53 st.writeln('import \'package:flutter/services.dart\' show rootBundle;'); 54 st.writeln('import \'package:flutter/services.dart\' show rootBundle;');
54 st.writeln('import \'package:flutter/widgets.dart\' show AssetImage;'); 55 st.writeln('import \'package:flutter/widgets.dart\' show AssetImage;');
55 st.writeln('import \'package:path_provider/path_provider.dart\';'); 56 st.writeln('import \'package:path_provider/path_provider.dart\';');
56 st.writeln('import \'package:printing/printing.dart\';'); 57 st.writeln('import \'package:printing/printing.dart\';');
57 - } else {  
58 - st.writeln('import \'dart:typed_data\';');  
59 } 58 }
60 st.writeln('import \'package:pdf/pdf.dart\';'); 59 st.writeln('import \'package:pdf/pdf.dart\';');
61 st.writeln('import \'package:pdf/widgets.dart\' as pw;'); 60 st.writeln('import \'package:pdf/widgets.dart\' as pw;');