当我尝试使用advance_pdf_viewer时,它会在控制台中抛出一个错误
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception:
MissingPluginException(No implementation found for method getPage on channel flutter_plugin_pdf_viewer)
E/flutter (11212): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
E/flutter (11212): <asynchronous suspension>
E/flutter (11212): #1 PDFDocument.get (package:advance_pdf_viewer/src/document.dart:97:18)
E/flutter (11212): <asynchronous suspension>
E/flutter (11212): #2 _PDFViewerState._loadPage (package:advance_pdf_viewer/src/viewer.dart:151:18)
E/flutter (11212): <asynchronous suspension>我正在尝试打开一个pdf通过链接传递给我的班级下面提到。每当我试图打开pdf,它就会抛出上面的错误。请帮我把这个修好。
import 'package:advance_pdf_viewer/advance_pdf_viewer.dart';
import 'package:flutter/material.dart';
class viewDoc extends StatefulWidget {
final doc;
final title;
const viewDoc({@required this.doc, @required this.title, Key? key})
: super(key: key);
@override
State<viewDoc> createState() => _viewDocState();
}
class _viewDocState extends State<viewDoc> {
bool isLoading = true;
var document;
PDFDocument? document1;
//final GlobalKey<SfPdfViewerState> _pdfViewerKey = GlobalKey();
PDFPage? pageOne;
@override
void initState() {
super.initState();
WidgetsBinding.instance!.addPostFrameCallback((_) async {
document1 = await PDFDocument.fromURL(widget.doc);
setState(() => isLoading = false);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Example'),
),
body: Center(
child: isLoading
? Center(child: CircularProgressIndicator())
: PDFViewer(document: document1!)),
);
}
}发布于 2022-09-27 18:57:02
它看起来是advance_pdf_viewer版本2.0.1中的一个问题,并在2.0.2中得到了修正,但是2.0.2还没有在pub.dev上发布(可能在将来)
这个提交修复了错误,直到。将advance_pdf_viewer替换为pubspec.yaml中的以下内容
advance_pdf_viewer:
git:
url: git@github.com:lohanidamodar/pdf_viewer.git
ref: 4e5d96be29de515f1081c0b6897741b8dca84722https://github.com/lohanidamodar/pdf_viewer/issues/117 https://github.com/lohanidamodar/pdf_viewer/issues/110
发布于 2022-11-04 13:46:39
如果应用程序仍然从Ozan Taskiran提供的解决方案中崩溃,尝试使用https版本(在Ozan Taskiran提供的第一个链接中找到)
advance_pdf_viewer:
git:
url: https://github.com/lohanidamodar/pdf_viewer.git
ref: 4e5d96be29de515f1081c0b6897741b8dca84722https://stackoverflow.com/questions/73872320
复制相似问题