Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing a PDF with layoutPdf fails to print: The 'net.nfet.printing' channel sent a message from native to Flutter on a non-platform thread #1638

Open
1 task done
AndyWerder opened this issue Mar 29, 2024 · 1 comment
Labels
bug Something isn't working needs triage

Comments

@AndyWerder
Copy link

AndyWerder commented Mar 29, 2024

Describe the bug
Re-testing a custom action in FlutterFlow that generates a PDF using the packages pdf and printing packages, I realize that the PDF gets generated but I cannot view it on my iOS devices. The custom action also stores the PDF in Google storage and that file can be viewed, so I'm certain that the PDF got properly generated. This has worked perfectly a few weeks ago and now no longer does, so must be an incompatibility with either an iOS change or a Flutter or new package version incompatibility. Note that the PDF still opens in Android, so it does not look like it's a generic Flutter (or FlutterFlow) issue. Versions used: pdf: ^3.10.7, printing: ^5.11.1 (5.12.0 makes no difference).
The error thrown in iOS produces a few lines in the Xcode console:
[ERROR:flutter/shell/common/shell.cc(1038)] The 'net.nfet.printing' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.
See https://docs.flutter.dev/platform-integration/platform-channels#channels-and-platform-threading for more information.

Expected behavior
Upon invoking the Printing.layout method (see code above), the iOS (or Android) print dialog appears. At this point the user can choose to print or cancel or whatever the PDF document. A thumbnail of the document should be visible within the dialog box but it is missing in iOS (while still present in Android). Selecting Print in iOS does not print the PDF.

To Reproduce
Code snippet to reproduce the behavior:
final Uint8List pdfData = await report.buildPdf(PdfPageFormat.letter); await Printing.layoutPdf(onLayout: (PdfPageFormat format) async => pdfData);

Screenshots
85C99F98-FFEC-499A-B37D-7B0FCA229174_1_201_a

Flutter Doctor
andreaswerder@Andreass-M3-MacBook-Pro a_p_test_app % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.4, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.87.2)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!

Desktop (please complete the following information):

  • Browser (Chrome on Mac OS14.4.1)

Smartphone (please complete the following information):

  • Device: [e.g. iPhone13, iPad mini 4]
  • OS: [e.g. iOS 17.4.1 / iPad OS 15.8.1]

Additional context

@AndyWerder AndyWerder added bug Something isn't working needs triage labels Mar 29, 2024
@mohanedsayed
Copy link

Hello @AndyWerder, I am facing the same problem currently, did you find any sort of a work around ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants