packages.flutter
packages.flutter copied to clipboard
[native_pdf_view] Fatal error on MacOS
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file native_pdf_renderer/NativePdfRendererPlugin.swift, line 60 Lost connection to device.
I'm using native_pdf_view I've been using the same code for a web app and it worked fine, but on MacOS I get the error. It seems to be crashing while initialising the PdfController.
Please retry with last version [native_pdf_view] v5.0.0
I still get the error on MacOS: Fatal error: Unexpectedly found nil while unwrapping an Optional value: file native_pdf_renderer/NativePdfRendererPlugin.swift, line 60 Lost connection to device.
I'll try it on Windows as soon as I get a chance to get on a windows pc.
I still get the error on MacOS: Fatal error: Unexpectedly found nil while unwrapping an Optional value: file
i cant reproduce bug on macOS Which version of flutter and nacOS you usage? What time What do you do at the time of departure? Can you attach a pdf file with which your application crashes? what additional arguments are you using?
If you use renderer:
renderer: (PdfPage page) => page.render(
width: page.width * 2,
height: page.height * 2,
format: PdfPageFormat.WEBP, <--
backgroundColor: '#FFFFFF',
),
MacOs does not support PdfPageFormat.WEBP
when i try usage it i handle same error:
Try specify PdfPageFormat.JPEG
I tried on both the stable and dev flutter channels. I'll try that direct edit in the renderer next, not sure how to do this though.
it already looked like this:
/// Default PdfRenderer options static Future<PdfPageImage?> _render(PdfPage page) => page.render( width: page.width * 2, height: page.height * 2, format: PdfPageFormat.JPEG, backgroundColor: '#ffffff', );
Also this catch is in the renderer code: async { if (format == PdfPageFormat.WEBP && (UniversalPlatform.isIOS || UniversalPlatform.isWindows)) { throw PdfNotSupportException( 'PDF Renderer on IOS & Windows platforms do not support WEBP format', ); }
but is error isn't being invoked
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file native_pdf_renderer/NativePdfRendererPlugin.swift, line 60 Lost connection to device. Exited (sigterm)
Looking at the file and line mentioned in the error the line reads: result(documents.register(renderer: renderer!).infoMap as NSDictionary)
the whole function:
func openDocumentAssetHandler(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void {
guard let name = call.arguments as! String? else {
return result(FlutterError(code: "RENDER_ERROR",
message: "Arguments not sended",
details: nil))
}
let renderer = openAssetDocument(name: name)
result(documents.register(renderer: renderer!).infoMap as NSDictionary)
}
I wonder if that nullcheck (renderer!) for some reason returns nil here
Problem throws after run builded release (flutter build, then run) or on local dev run (flutter run) ?
Has this been resolved? I just ran into this same error ...