I am using the plugin url_launcher in my Flutter app. It is working fine, but it works different on Android and on iOS devices.

The used URL proposes the download of a PDF file on Android and shows the PDF on iOS.

This is the code:

_launchURL(String codigo) async {
    String url = 'https://...pdftest.php?cod='+codigo;
    if (await canLaunch(url)) {
      await launch(url,forceWebView: true, enableJavaScript: true,enableDomStorage: true);
    } else {
      throw 'Could not launch $url';
    }
  }

Here you have the output on iOS:

enter image description here

On Android, the output without the parameters

forceWebView: true, enableJavaScript: true,enableDomStorage: true

the output is as follows:

enter image description here

Is there a way to force the PDF show on Android? Or should I download the file and then open it from the device?


Solution 1: Omar Mahmoud

You can open PDF in Google Docs Viewer to make both behave the same

http://docs.google.com/gview?embedded=true&url=<URL>