skip to Main Content

I am getting the list of the pdfs from the firebase storage. I am using advance_pdf_viewer to view the pdf but as soon as the file is passed to the pdf reader, my emulator crashes with following error.E/AndroidRuntime(31096): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(31096): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:430)
E/AndroidRuntime(31096): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:267)
E/AndroidRuntime(31096): at pt.tribeiro.flutter_plugin_pdf_viewer.FlutterPluginPdfViewerPlugin$1$2.run(FlutterPluginPdfViewerPlugin.java:92)
E/AndroidRuntime(31096): at android.os.Handler.handleCallback(Handler.java:873)
E/AndroidRuntime(31096): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(31096): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(31096): at android.app.ActivityThread.main(ActivityThread.java:7073)
E/AndroidRuntime(31096): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31096): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
E/AndroidRuntime(31096): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
E/flutter (31096): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method getPage on channel flutter_plugin_pdf_viewer)

class FilePage extends StatefulWidget {
  const FilePage({required this.file, this.isImage = false});
  final FirebaseFile file;
  final isImage;
  @override
  _FilePageState createState() => _FilePageState();
}

class _FilePageState extends State<FilePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {

    //initState(){
    return WillPopScope(
      onWillPop: () async => true,
      child: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.indigo[900],
          title: Text(widget.file.name.split('.').first),
          centerTitle: true,
        ),
        body: widget.isImage
            ? loadImage(widget.file.url)
            : FutureBuilder(
            future: PDFDocument.fromURL(widget.file.url),
            builder: (context, snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.waiting:
                case ConnectionState.active:
                  return Center(
                    child: CircularProgressIndicator(),
                  );
                default:
                  var pdf = snapshot.data as PDFDocument;
                  return PDFViewer(document: pdf);
              }
            }),
      ),
    );
  }

  Widget loadImage(String url) {
    return Image.network(
      url,
      loadingBuilder: (context, widget, event) {
        if (event == null) return widget;
        return Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              CircularProgressIndicator(),
              SizedBox(
                height: 20,
              ),
              Text('Loading')
            ],
          ),
        );
      },
    );
  }
}

2

Answers


  1. You can try flutter clean and rebuild the application. This worked for me when I was facing similar issue

    Login or Signup to reply.
  2. I have also faced this issued but finally I got solution. This issue occur in this version (advance_pdf_viewer 2.0.1). But in version 2.0.2 is perfectaly worked. version 2.0.2 is not available in pub.dev.

    I found this answer from this : https://github.com/lohanidamodar/pdf_viewer/issues/117

    You can add this lines in your pubspec.yaml

    advance_pdf_viewer:
        git:
          url: https://github.com/lohanidamodar/pdf_viewer.git
          ref: 4e5d96be29de515f1081c0b6897741b8dca84722
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search