Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App clash after build the apk #5

Open
Silerqin opened this issue Mar 10, 2020 · 1 comment
Open

App clash after build the apk #5

Silerqin opened this issue Mar 10, 2020 · 1 comment

Comments

@Silerqin
Copy link

I am using flutter_pdfview which is version ^1.0.0+10 to open a PDF file in flutter apps. When my app is in debug mode, there is no error. After I build the app the PDF file cannot open in apps. My app will clash and close the app suddenly. I have open the permission in AndroidManifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Here is my code:

@override
  Widget build(BuildContext context) {
    return MaterialApp(
        body: Center(
          child: Builder(
            builder: (context) => Column(children: <Widget>[
                    RaisedButton(child: Text("Open PDF "),onPressed: () {
                     Navigator.push(context,MaterialPageRoute(builder: (context) =>
                       PdfViewPage(path: '/storage/emulated/0/Download/$pdfName')));
                        }
                      },
                    )
                  ],
                ),
          ),
        ),
      ),
    );
  }
}

class PdfViewPage extends StatefulWidget {
  final String path;

  const PdfViewPage({Key key, this.path}) : super(key: key);
  @override
  _PdfViewPageState createState() => _PdfViewPageState();
}

class _PdfViewPageState extends State<PdfViewPage> {
  int _totalPages = 0;
  int _currentPage = 0;
  bool pdfReady = false;
  PDFViewController _pdfViewController;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
      ),
      body: Stack(
        children: <Widget>[
          PDFView(
            filePath: widget.path,
            autoSpacing: true,
            enableSwipe: true,
            pageSnap: true,
            swipeHorizontal: true,
            nightMode: false,
            onError: (e) {
              print(e);
            },
            onRender: (_pages) {
              setState(() {
                _totalPages = _pages;
                pdfReady = true;
              });
            },
            onViewCreated: (PDFViewController vc) {
              _pdfViewController = vc;
            },
            onPageChanged: (int page, int total) {
              setState(() {});
            },
            onPageError: (page, e) {},
          ),
          !pdfReady
              ? Center(
                  child: CircularProgressIndicator(),
                )
              : Offstage()
        ],
      ),
    );
  }
}

How can solve this error? Thanks in advanced

@RomeoDar
Copy link

RomeoDar commented Apr 6, 2020

Did You Find Any Solutiuon Yet ?
https://stackoverflow.com/questions/60617934/how-to-open-pdf-file-in-the-app-using-flutter (Proguard-rule solve this issue or not ? )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants