lohanidamodar / pdf_viewer

A flutter plugin for handling PDF files. Works on both Android & iOS

Home Page:https://pub.dev/packages/advance_pdf_viewer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to open PDF File on android

insightopera opened this issue · comments

Screenshot_1625916694

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building NotificationListener<KeepAliveNotification>:
Null check operator used on a null value

The relevant error-causing widget was
PDFViewer
lib/components/pdfViewer.dart:107
When the exception was thrown, this was the stack
#0      _PDFPageState._repaint
package:advance_pdf_viewer/src/page.dart:54
#1      _PDFPageState.didChangeDependencies
package:advance_pdf_viewer/src/page.dart:42

I have working where I create a pdf file and display on page.
It is working fine on ios devices.
But on android devices, it is showing this error message. Even share button is also sharing file but pdf view showing this error.
Please help to solve this error. After upgrade flutter 2 i am getting this message.

[✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.7 19H1217 darwin-x64, locale en-PK)
    • Flutter version 2.2.2 at /Users/student/Developer/flutter_2
    • Framework revision d79295af24 (4 weeks ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/student/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    ✗ Xcode 11.5.0 out of date (12.0.1 is recommended).
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.58.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[✓] Connected device (3 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86    • Android 9 (API 28) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • Mac OS X 10.15.7 19H1217 darwin-x64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 91.0.4472.114

! Doctor found issues in 1 category.

Did you found a solution?

Did you found a solution?

No, But I changed the plugin which is working fine.

commented

I am also facing this error. @amaajid001 which plugin are you using now ?

I'm also having this issue.
It seems that on the first try to open the file it returns null from here:
var data = await _channel .invokeMethod('getPage', {'filePath': _filePath, 'pageNumber': page});
(From document.dart file)
And the interesting thing is that after I reopen my app everything works fine

Edit:
This patch solved this exception for me:
I have noticed that before I reopen the application (which solves the issue) and I try to open the PDF, I'm getting this exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.app.Activity.getResources()' on a null object reference

But when I reopen the app and everything works, this exception disappears. So, I have looked for this exception in this repository issues and encountered this fix:
#45

After implementing RasyidMF solution, the PDF opens correctly.

I am also facing this error. @amaajid001 which plugin are you using now ?

I am using syncfusion_flutter_pdfviewer this package.

commented

I am also facing this error. @amaajid001 which plugin are you using now ?

I am using syncfusion_flutter_pdfviewer this package.

This syncfusion_flutter_pdfviewer works very well, too bad it is not a free package.

I am also facing this error. @amaajid001 which plugin are you using now ?

I am using syncfusion_flutter_pdfviewer this package.

This syncfusion_flutter_pdfviewer works very well, too bad it is not a free package.

Its free brother. I am using it.

commented

Its free brother. I am using it.

You applied for the community license ?

Its free brother. I am using it.

You applied for the community license ?

No Just installed package from pub,dev
https://pub.dev/packages/syncfusion_flutter_pdfviewer

commented

Its free brother. I am using it.

You applied for the community license ?

No Just installed package from pub,dev
https://pub.dev/packages/syncfusion_flutter_pdfviewer

But it stated "Disclaimer: This is a commercial package. To use this package, you need to have either a Syncfusion commercial license or Free Syncfusion Community license."

I have never used this kind of package before. Does it mean that we will have to have a license if we want to publish our app the app store?

Any news on this topic or should I use another library?

Any news on this topic or should I use another library?

Go get another library named pdf_native_viewer by serge.software