Search code examples
flutterfirebasegoogle-cloud-firestorepdf-viewer

I want to view file like pdf,doc,pptx and etc in my flutter app using url and I don't want to store any file in device


I want to view file like pdf,doc,pptx and etc in my flutter app using url and I don't want to store any file in device


Solution

  • You can use the flutter_webview_plugin package to display files in your Flutter app without downloading or storing them on the device. Here is an example of how to use it to display PDF files:

    Add the flutter_webview_plugin package to your pubspec.yaml file and run flutter pub get to install it.

    Import the package in your Dart code:

    import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

    Use the WebviewScaffold widget to display the PDF file:

    WebviewScaffold( url: 'https://example.com/path/to/file.pdf', withZoom: true, withLocalStorage: true, );

    The url parameter should point to the URL of the PDF file you want to display. The withZoom and withLocalStorage parameters are optional and control whether the user can zoom in and out of the file and whether any local storage is used for caching.

    You can use the same approach to display other types of files, such as Microsoft Office documents and PowerPoint presentations, as long as the file is accessible via a URL.