flutter_plugin_pdf_viewer
flutter_plugin_pdf_viewer copied to clipboard
it will conflict with flutter_workmanager plugin on Android
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
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.