Open ketanchoyal opened 5 years ago
Solved using this function
Future<File> getFileFromUrl(String url) async { try { var data = await http.get(url); var bytes = data.bodyBytes; var dir = await getApplicationDocumentsDirectory(); String fileName = createCryptoRandomString(8); File file = File("${dir.path}/$fileName.pdf"); File urlFile = await file.writeAsBytes(bytes); return urlFile; } catch (e) { throw Exception("Error opening url file"); } }
and instead of from Url :
doc = await PDFDocument.fromAsset((await getFileFromUrl(url)).path);
W/System.err(24726): java.io.IOException: Unable to create temporary file, /data/user/0/com.mappdeveloper.usa.our_e_school/cache/.our_e_school/cache/libCachedImageData/12db2cc0-aeb8-11e9-da48-ed04b1df2afe-0.png7920165209647190097.tmp W/System.err(24726): at java.io.File$TempDirectory.generateFile(File.java:1911) W/System.err(24726): at java.io.File.createTempFile(File.java:2001) W/System.err(24726): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.createTempPreview(FlutterPluginPdfViewerPlugin.java:104) W/System.err(24726): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.getPage(FlutterPluginPdfViewerPlugin.java:141) W/System.err(24726): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin.access$100(FlutterPluginPdfViewerPlugin.java:28) W/System.err(24726): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1.run(FlutterPluginPdfViewerPlugin.java:68) W/System.err(24726): at android.os.Handler.handleCallback(Handler.java:873) W/System.err(24726): at android.os.Handler.dispatchMessage(Handler.java:99) W/System.err(24726): at android.os.Looper.loop(Looper.java:193) W/System.err(24726): at android.os.HandlerThread.run(HandlerThread.java:65) I/flutter (24726): Another exception was thrown: Invalid argument(s) (path): Must not be null I/flutter (24726): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following child: W/System (24726): A resource failed to call close.