Home > Software design >  Flutter how to open pdf using web browser
Flutter how to open pdf using web browser

Time:08-12

How to open pdf from url address in flutter? I try call window like this: enter image description here

And select there application for open pdf file. I try do it using libraries:

But none of them cannot do it. Any ideas or samples?

CodePudding user response:

You can force webview using

Future<void> _launchInBrowser(Uri url) async {
    if (!await launchUrl(
      url,
      mode: LaunchMode.externalApplication,
    )) {
      throw 'Could not launch $url';
    }
  }

or to load it in an inapp web view

Future<void> _launchInWebViewOrVC(Uri url) async {
    if (!await launchUrl(
      url,
      mode: LaunchMode.inAppWebView,
      webViewConfiguration: const WebViewConfiguration(
          headers: <String, String>{'my_header_key': 'my_header_value'}),
    )) {
      throw 'Could not launch $url';
    }
  }
  • Related