iampawan / iampawan/FlutterPDFViewer

App clash after build the apk

Open
#5 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
73
Forks
35
PR merge metrics
No merged PRs in 30d

Description

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:

```

```

Here is my code:

```
@override
Widget build(BuildContext context) {
return MaterialApp(
body: Center(
child: Builder(
builder: (context) => Column(children: [
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 {
int _totalPages = 0;
int _currentPage = 0;
bool pdfReady = false;
PDFViewController _pdfViewController;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
),
body: Stack(
children: [
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.