FlutterPDFViewer
FlutterPDFViewer copied to clipboard
App clash after build the apk
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
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 ? )