PDFView cannot read pdf from firestorage or url

121 Views Asked by At

I am using PDFView plugin to read pdf but whenever I pass the url to it,the pdf doesnot load. I did not receive any of the error but pdf does not open. I am getting the pdf url from the firebase storage.

class FilePage extends StatefulWidget {
   FilePage({required this.file, this.isImage = false});
  final FirebaseFile file;
  final isImage;

  _FilePageState createState() => _FilePageState();
}

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

  @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: _isLoading? const
        Center( child: CircularProgressIndicator() )
            :
        PDFView(
          filePath: widget.file.url,
          preventLinkNavigation: false,


        )
      ),
    );
  }

}
1

There are 1 best solutions below

3
Kaushik Chandru On

Are you setting this variable to false after its loaded?

return WillPopScope(
      onWillPop: () async => true,
      child: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.indigo[900],
          title: Text(widget.file.name
              .split('.')
              .first),
          centerTitle: true,
        ),
        body: PDFView(
          filePath: widget.file.url,
          preventLinkNavigation: false,
        )
      ),
    );