flutter_plugin_pdf_viewer icon indicating copy to clipboard operation
flutter_plugin_pdf_viewer copied to clipboard

it will conflict with flutter_workmanager plugin on Android

Open winsonet opened this issue 5 years ago • 1 comments

when I try to work with flutter_workmanager it show below error:

I/System.out( 7995): Attempt to invoke virtual method 'android.content.res.Resources android.app.Activity.getResources()' on a null object reference
W/System.err( 7995): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.app.Activity.getResources()' on a null object reference
W/System.err( 7995): 	at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.getPage(FlutterPluginPdfViewerPlugin.java:128)
W/System.err( 7995): 	at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.access$100(FlutterPluginPdfViewerPlugin.java:28)
W/System.err( 7995): 	at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1.run(FlutterPluginPdfViewerPlugin.java:68)
W/System.err( 7995): 	at android.os.Handler.handleCallback(Handler.java:873)
W/System.err( 7995): 	at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err( 7995): 	at android.os.Looper.loop(Looper.java:193)
W/System.err( 7995): 	at android.os.HandlerThread.run(HandlerThread.java:65)

I read the source code and find below

 Future<PDFPage> get({int page = 1}) async {
    assert(page > 0);
    var data = await _channel
        .invokeMethod('getPage', {'filePath': _filePath, 'pageNumber': page});
    return new PDFPage(data, page);
  }

it will return to null, I just start the backgound task with flutter_workmanager even nothing to do it will also cause the PDFViewer failed

I also read the plugin's java code and seems will also use the backgound handler, I am not sure whether the background process will be conflict with flutter_workmanager

but it works well on iOS

winsonet avatar Oct 16 '19 04:10 winsonet

I have the same problem, I'm using flutter_downloader, it uses background processes, when I make a download and then try to open a pdf file, I got an error saying Invalid argument(s) (path): Must not be null. if I restart my app and don't make a download everything woks fine.

RafaelR7 avatar Dec 18 '19 12:12 RafaelR7