David PHAM-VAN

Update listener handling flutter/flutter#32936

  1 +# Changelog
  2 +
1 ## 2.1.0 3 ## 2.1.0
2 4
3 -* Add html to pdf platform conversion 5 +- Add html to pdf platform conversion
  6 +- Fix issue with flutter 1.6.2+
4 7
5 ## 2.0.4 8 ## 2.0.4
6 9
7 -* Update Readme 10 +- Update Readme
8 11
9 ## 2.0.3 12 ## 2.0.3
10 13
11 -* Add file save and view to example application  
12 -* Convert print screen example to Widgets  
13 -* Deprecate the document argument in Printing.sharePdf() 14 +- Add file save and view to example application
  15 +- Convert print screen example to Widgets
  16 +- Deprecate the document argument in Printing.sharePdf()
14 17
15 ## 2.0.2 18 ## 2.0.2
16 19
17 -* Fix example application 20 +- Fix example application
18 21
19 ## 2.0.1 22 ## 2.0.1
20 23
21 -* Fix Replace FlutterErrorDetails to be compatible with Dart 2.3.0 24 +- Fix Replace FlutterErrorDetails to be compatible with Dart 2.3.0
22 25
23 ## 2.0.0 26 ## 2.0.0
24 27
25 -* Breaking change: Switch libraries to AndroidX  
26 -* Add Page information to PdfDoc object 28 +- Breaking change: Switch libraries to AndroidX
  29 +- Add Page information to PdfDoc object
27 30
28 ## 1.3.5 31 ## 1.3.5
29 32
30 -* Restore compatibility with Flutter 1.0.0  
31 -* Update code to Dart 2.1.0  
32 -* Depends on pdf 1.3.3 33 +- Restore compatibility with Flutter 1.0.0
  34 +- Update code to Dart 2.1.0
  35 +- Depends on pdf 1.3.3
33 36
34 ## 1.3.4 37 ## 1.3.4
35 38
36 -* Fix iOS build with Swift  
37 -* Add installation instructions in the Readme  
38 -* Follow Flutter debug painting settings 39 +- Fix iOS build with Swift
  40 +- Add installation instructions in the Readme
  41 +- Follow Flutter debug painting settings
39 42
40 ## 1.3.3 43 ## 1.3.3
41 44
42 -* Fix dart lint warnings  
43 -* Add documentation  
44 -* Add a filename parameter for sharing  
45 -* Convert Objective-C code to Swift  
46 -* Update Readme 45 +- Fix dart lint warnings
  46 +- Add documentation
  47 +- Add a filename parameter for sharing
  48 +- Convert Objective-C code to Swift
  49 +- Update Readme
47 50
48 ## 1.3.2 51 ## 1.3.2
49 52
50 -* Fix iOS printing issues 53 +- Fix iOS printing issues
51 54
52 ## 1.3.1 55 ## 1.3.1
53 56
54 -* Fix pana linting notices 57 +- Fix pana linting notices
55 58
56 ## 1.3.0 59 ## 1.3.0
57 60
58 -* Add a Flutter like widget system 61 +- Add a Flutter like widget system
59 62
60 ## 1.2.0 63 ## 1.2.0
61 64
62 -* Fix compileSdkVersion to match appcompat  
63 -* Change license to Apache 2.0  
64 -* Implement asynchronous printing driven by the OS 65 +- Fix compileSdkVersion to match appcompat
  66 +- Change license to Apache 2.0
  67 +- Implement asynchronous printing driven by the OS
65 68
66 ## 1.1.0 69 ## 1.1.0
67 70
68 -* Rename classes to satisfy Dart conventions  
69 -* Remove useless new and const keywords  
70 -* Changed appcompat dependency to 26.1.0 71 +- Rename classes to satisfy Dart conventions
  72 +- Remove useless new and const keywords
  73 +- Changed appcompat dependency to 26.1.0
71 74
72 ## 1.0.6 75 ## 1.0.6
73 76
74 -* Add screenshot example 77 +- Add screenshot example
75 78
76 ## 1.0.5 79 ## 1.0.5
77 80
78 -* Fix printing from pdf document 81 +- Fix printing from pdf document
79 82
80 ## 1.0.4 83 ## 1.0.4
81 84
82 -* Update example for pdf 1.0.5  
83 -* Add Contributing 85 +- Update example for pdf 1.0.5
  86 +- Add Contributing
84 87
85 ## 1.0.3 88 ## 1.0.3
86 89
87 -* Update source formatting  
88 -* Update README 90 +- Update source formatting
  91 +- Update README
89 92
90 ## 1.0.2 93 ## 1.0.2
91 94
92 -* Add License file  
93 -* Updated homepage 95 +- Add License file
  96 +- Updated homepage
94 97
95 ## 1.0.1 98 ## 1.0.1
96 99
97 -* Fixed sdk version 100 +- Fixed sdk version
98 101
99 ## 1.0.0 102 ## 1.0.0
100 103
101 -* Initial release. 104 +- Initial release.
@@ -40,16 +40,15 @@ Future<PdfImage> pdfImageFromImageProvider( @@ -40,16 +40,15 @@ Future<PdfImage> pdfImageFromImageProvider(
40 final ImageStream stream = 40 final ImageStream stream =
41 image.resolve(configuration ?? ImageConfiguration.empty); 41 image.resolve(configuration ?? ImageConfiguration.empty);
42 42
43 - Future<void> listener(ImageInfo image, bool sync) async { 43 + ImageStreamListener listener;
  44 + listener = ImageStreamListener((ImageInfo image, bool sync) async {
44 final PdfImage result = 45 final PdfImage result =
45 await pdfImageFromImage(pdf: pdf, image: image.image); 46 await pdfImageFromImage(pdf: pdf, image: image.image);
46 if (!completer.isCompleted) { 47 if (!completer.isCompleted) {
47 completer.complete(result); 48 completer.complete(result);
48 } 49 }
49 stream.removeListener(listener); 50 stream.removeListener(listener);
50 - }  
51 -  
52 - void errorListener(dynamic exception, StackTrace stackTrace) { 51 + }, onError: (dynamic exception, StackTrace stackTrace) {
53 if (!completer.isCompleted) { 52 if (!completer.isCompleted) {
54 completer.complete(null); 53 completer.complete(null);
55 } 54 }
@@ -59,9 +58,9 @@ Future<PdfImage> pdfImageFromImageProvider( @@ -59,9 +58,9 @@ Future<PdfImage> pdfImageFromImageProvider(
59 // https://groups.google.com/forum/#!topic/flutter-announce/hp1RNIgej38 58 // https://groups.google.com/forum/#!topic/flutter-announce/hp1RNIgej38
60 assert(false, 'image failed to load'); 59 assert(false, 'image failed to load');
61 } 60 }
62 - } 61 + });
63 62
64 - stream.addListener(listener, onError: errorListener); 63 + stream.addListener(listener);
65 return completer.future; 64 return completer.future;
66 } 65 }
67 66