David PHAM-VAN

Remove unnecessary _raster call in PdfPreview

# Pdf for Dart and Flutter
![Dart CI](https://github.com/DavBfr/dart_pdf/workflows/Dart%20CI/badge.svg)
[![pub package](https://img.shields.io/pub/v/pdf.svg)](https://pub.dartlang.org/packages/pdf)
[![pub package](https://img.shields.io/pub/v/printing.svg)](https://pub.dartlang.org/packages/printing)
[![codecov](https://codecov.io/gh/DavBfr/dart_pdf/branch/master/graph/badge.svg)](https://codecov.io/gh/DavBfr/dart_pdf)
![Dart CI](https://github.com/DavBfr/dart_pdf/workflows/Dart%20CI/badge.svg) [![pub package](https://img.shields.io/pub/v/pdf.svg)](https://pub.dartlang.org/packages/pdf) [![pub package](https://img.shields.io/pub/v/printing.svg)](https://pub.dartlang.org/packages/printing) [![codecov](https://codecov.io/gh/DavBfr/dart_pdf/branch/master/graph/badge.svg)](https://codecov.io/gh/DavBfr/dart_pdf)
This set of plugins allows Flutter apps to generate and print pdf files to the device printer. This plugin works for iOS and Android.
* dart pdf: <https://pub.dev/packages/pdf>
* flutter printing: <https://pub.dev/packages/printing>
* Live Demo: <https://davbfr.github.io/dart_pdf/>
- dart pdf: <https://pub.dev/packages/pdf>
- flutter printing: <https://pub.dev/packages/printing>
- Live Demo: <https://davbfr.github.io/dart_pdf/>
[![Buy Me A Coffee](https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png "Buy Me A Coffee")](https://www.buymeacoffee.com/JORBmbw9h "Buy Me A Coffee")
## Contributing
Follow the instructions here: [contributing](CONTRIBUTING.md).
A Makefile is available on the project root directory to download and prepare the dependencies.
... ...
... ... @@ -66,10 +66,11 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
initialIndex: _tab,
);
_tabController!.addListener(() {
setState(() {
_tab = _tabController!.index;
print('set state 1');
});
if (_tab != _tabController!.index) {
setState(() {
_tab = _tabController!.index;
});
}
if (examples[_tab].needsData && !_hasData && !_pending) {
_pending = true;
askName(context).then((value) {
... ... @@ -86,7 +87,6 @@ class MyAppState extends State<MyApp> with SingleTickerProviderStateMixin {
setState(() {
printingInfo = info;
print('set state 2');
});
}
... ...
... ... @@ -3,6 +3,7 @@
## 5.0.5
- Fix PdfPreview timer dispose [wwl901215]
- Remove unnecessary _raster call in PdfPreview [yaymalaga]
## 5.0.4
... ...
... ... @@ -128,6 +128,8 @@ class _PdfPreviewState extends State<PdfPreview> {
Timer? previewUpdate;
var _rastering = false;
static const defaultPageFormats = <String, PdfPageFormat>{
'A4': PdfPageFormat.a4,
'Letter': PdfPageFormat.letter,
... ... @@ -138,6 +140,11 @@ class _PdfPreviewState extends State<PdfPreview> {
: pageFormat;
Future<void> _raster() async {
if (_rastering) {
return;
}
_rastering = true;
Uint8List _doc;
if (!info.canRaster) {
... ... @@ -154,6 +161,7 @@ class _PdfPreviewState extends State<PdfPreview> {
return true;
}());
_rastering = false;
return;
}
... ... @@ -177,6 +185,7 @@ class _PdfPreviewState extends State<PdfPreview> {
informationCollector: collector,
));
error = exception;
_rastering = false;
return;
}
... ... @@ -193,6 +202,7 @@ class _PdfPreviewState extends State<PdfPreview> {
pages: widget.pages,
)) {
if (!mounted) {
_rastering = false;
return;
}
setState(() {
... ... @@ -213,6 +223,7 @@ class _PdfPreviewState extends State<PdfPreview> {
}
pages.removeRange(pageNum, pages.length);
_rastering = false;
}
@override
... ... @@ -256,7 +267,6 @@ class _PdfPreviewState extends State<PdfPreview> {
if (oldWidget.build != widget.build) {
preview = null;
updatePosition = null;
pages.clear();
_raster();
}
super.didUpdateWidget(oldWidget);
... ...