flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.01k stars 27.19k forks source link

[url_launcher] Opening PDF URLs on Android with in-app mode (without Custom Tabs) shows a white screen #105205

Open keitheyre opened 2 years ago

keitheyre commented 2 years ago

Running on Android physical device - (Galaxy Tab A7 - WiFi) url_launcher: ^6.1.2 Android Studio Bumblebee | 2021.1.1 Patch 3

Issue: I am trying to open a Firebase Storage URL from the device using the following code:

void launchURL(url) async {
      Uri uri = Uri.parse(url);
    if (await canLaunchUrl(uri)) {
      await launchUrl(uri);
    } else {
      throw 'Could not launch $url';
    }
  }

This is the result:

image
flutter doctor -v ``` [✓] Flutter (Channel stable, 2.10.5, on macOS 12.4 21F79 darwin-x64, locale en-IE) • Flutter version 2.10.5 at /Users/keitheyre/Documents/DEV/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5464c5bac7 (6 weeks ago), 2022-04-18 09:55:37 -0700 • Engine revision 57d3bac3dd • Dart version 2.16.2 • DevTools version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/keitheyre/Library/Android/sdk • Platform android-31, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822) [✓] Connected device (2 available) • SM T510 (mobile) • R52MA1ESSTY • android-arm • Android 11 (API 30) • Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.99 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```
danagbemava-nc commented 2 years ago

Hi @keitheyre, can you share any link you're experiencing this issue with so that we can investigate this?

Thank you

keitheyre commented 2 years ago

Hey there!

The link is an https firebase storage link, I cannot share as it's private I'm afraid.

I did notice something though, on iOS the files seem to open with no issue. I have followed all the instructions to get them to open on Android but to no avail.

It just opens a white screen and hangs there until I press the back button on the device to return back to the Screen where the Open button is located.

Thank you, Keith

danagbemava-nc commented 2 years ago

Hi @keitheyre, what type of file is the link supposed to open? Does the link open a browser/webview or another app?

Also, can you confirm if this works in a native android project?

keitheyre commented 2 years ago

Hi @keitheyre, what type of file is the link supposed to open? Does the link open a browser/webview or another app?

Also, can you confirm if this works in a native android project?

Hey,

the file is a single page PDF. Yes the link opens perfectly on a browser on a computer.

I want the file to be opened in a browser.

Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.

Open -> opens file but when you press back, the app has crashed.

Download -> haven’t tried this yet as it doesn’t work with the flow of my app.

Yes I can confirm the same link works in native android app

I am free to call if you want to discuss this in real-time.

danagbemava-nc commented 2 years ago

Hi @keitheyre, does this bug still occur if you use LaunchMode.externalApplication?

Also, is this an issue with only PDF links or generally any link that you get from firestore?

keitheyre commented 2 years ago

Hey,

I have updated the code to the following:

void launchURL(url) async {
    if (await canLaunchUrlString(url)) {
      Uri uri = Uri.parse(url);
      print(url);
      await launchUrl(url, mode: LaunchMode.externalApplication);
    } else {
      throw 'Could not launch $url';
    }
  }

The url parameter is a String, a valid url as I have copied and pasted it into an Incognito Browser tab on my Mac. Opens perfectly.

After adding the LaunchMode.externalApplication the results are:

PDF:

  1. Browser opened, [Download or Open]
  2. Clicked Open,
  3. Opened PDF perfectly
  4. Clicked back (brings me back to an empty browser)
  5. Clicked back again
  6. Brings me back to the crashed app with "Lost connection to device"

PNG:

  1. Open in browser for viewing perfectly.
  2. Back button works perfectly

.doc

  1. Starts downloading immediately
  2. Does not open in a browser to view

Different .pdf

Same problem as above. the back button is returning to a white app screen with no errors other than Lost connection

danagbemava-nc commented 2 years ago

Hi @keitheyre, thanks for the extra information.

I found a firebase storage URL somewhere online and I was able to reproduce the white screen. Below are my observations

Observations

I haven't tested opening a webview in native android yet, so there's a chance this issue might be reproducing when using the webview option in native android as well.

Will investigate that later and report back.

For now, leaving this for further insight from the team.

android sample ```kotlin package com.nexus.launchurl import android.content.Intent import android.net.Uri import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.widget.Button class MainActivity : AppCompatActivity() { private lateinit var btnLaunch: Button override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) initButton() } private fun initButton() { btnLaunch = findViewById(R.id.btnLaunch) btnLaunch.setOnClickListener { val myIntent = Intent(Intent.ACTION_VIEW, Uri.parse(URL)) startActivity(myIntent) } } companion object { const val URL = "https://firebasestorage.googleapis.com/v0/b/realtime-chat-46f4c.appspot.com/o/documents%2Fbf307aa5-79ae-4532-8128-ee394537b357.pdf?alt=media&token=2d0c5329-4717-4adc-9418-6614913e5bfa" } } ```
flutter code sample ```dart import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; final Uri _url = Uri.parse('https://firebasestorage.googleapis.com/v0/b/realtime-chat-46f4c.appspot.com/o/documents%2Fbf307aa5-79ae-4532-8128-ee394537b357.pdf?alt=media&token=2d0c5329-4717-4adc-9418-6614913e5bfa'); void main() => runApp( const MaterialApp( home: Material( child: Center( child: ElevatedButton( onPressed: _launchUrl, child: Text('Open URL'), ), ), ), ), ); void _launchUrl() async { if (!await launchUrl(_url)) throw 'Could not launch $_url'; } ```
flutter doctor -v ``` [✓] Flutter (Channel stable, 3.0.1, on macOS 12.3.1 21E258 darwin-arm, locale en-GB) • Flutter version 3.0.1 at /Users/nexus/dev/sdks/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision fb57da5f94 (2 weeks ago), 2022-05-19 15:50:29 -0700 • Engine revision caaafc5604 • Dart version 2.17.1 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/nexus/Library/Android/sdk • Platform android-32, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] VS Code (version 1.67.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.42.0 [✓] Connected device (4 available) • M2007J20CG (mobile) • 5dd3be00 • android-arm64 • Android 11 (API 30) • Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 15.5 19F77 • macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ``` ``` [✓] Flutter (Channel master, 3.1.0-0.0.pre.1114, on macOS 12.3.1 21E258 darwin-arm, locale en-GB) • Flutter version 3.1.0-0.0.pre.1114 at /Users/nexus/dev/sdks/flutters • Upstream repository https://github.com/flutter/flutter.git • Framework revision 82ae61214a (6 hours ago), 2022-06-05 21:23:05 -0400 • Engine revision 73c59433b5 • Dart version 2.18.0 (build 2.18.0-170.0.dev) • DevTools version 2.14.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/nexus/Library/Android/sdk • Platform android-32, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] VS Code (version 1.67.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.42.0 [✓] Connected device (4 available) • M2007J20CG (mobile) • 5dd3be00 • android-arm64 • Android 11 (API 30) • Nexus (mobile) • 00008020-001875E83A38002E • ios • iOS 15.5 19F77 • macOS (desktop) • macos • darwin-arm64 • macOS 12.3.1 21E258 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.61 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```
keitheyre commented 2 years ago

Hi @danagbemava-nc

I have confirmed on my end with our Native Android App that the same links work but we handled it differently within our Android App. We instead check the type of file and decide what to do then.

Am I right in saying there is an issue here with the package? Should I wait for an update or go ahead and implement another solution for the above task?

Thanks again, Keith

DjordjeMancic97 commented 2 years ago

I also experience this issue, everything same as above mentioned. In my case it mostly happens when url is pointing to online pdf file.

stuartmorgan commented 2 years ago

Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.

By default I believe launch will use an external browser in Android, whereas launchUrl will open in the app, which may explain this difference.

keitheyre commented 2 years ago

Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.

By default I believe launch will use an external browser in Android, whereas launchUrl will open in the app, which may explain this difference.

I have tried all LaunchModes and ended up making my own custom camera manager for Android to combat this issue.

I have read that certain devices are prone to this problem but we are locked in with this specific device.

If there is any fixes in the future I would greatly appreciate an email Thanks

keith

stuartmorgan commented 2 years ago

The most likely explanation based on the repro description is that we need an extra delegate wired up for the in-app webview to deal with unhandled content (e.g., to prompt to download). If that's the case, we'll need to figure out how to manage this without the in-app version becoming as complex as webview_flutter itself.

akashgk commented 2 years ago

Im facing the same issue. It works great in case of iOS Apps. the Url opens up the PDF file. But in case of Android the user is shown a blank white screen. In case of setting the launch mode to external application the user is taken to the Browser and the file is being downloaded. This is not the experience I was looking for. I'm looking for something similar to iOS.

Have raised an issue on stack overflow as well. https://stackoverflow.com/questions/73733310/flutter-url-launcher-showing-white-screen-for-pdf-file-on-gcp-storage-android

Some logs which might be useful

/UrlLauncher(24742): component name for https://storage.googleapis.com/files/FAKE_FILE.pdf is {com.android.chrome/com.google.android.apps.chrome.IntentDispatcher}
I/ViewRootImpl@67ff2f9[MainActivity](24742): MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputTransport(24742): Input channel destroyed: 'ClientS', fd=128
I/ViewRootImpl@67ff2f9[MainActivity](24742): handleAppVisibility mAppVisible=true visible=false
I/SurfaceView@901753(24742): onWindowVisibilityChanged(8) false io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274} of ViewRootImpl@67ff2f9[MainActivity]
I/SurfaceView@901753(24742): pST: mTmpTransaction.apply, mTmpTransaction = android.view.SurfaceControl$Transaction@9262987
I/SurfaceView@901753(24742): surfaceDestroyed callback.size 1 #2 io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274}
I/SurfaceView@901753(24742): updateSurface: mVisible = false mSurface.isValid() = true
I/SurfaceView@901753(24742): tryReleaseSurfaces: set mRtReleaseSurfaces = true
I/SurfaceView@901753(24742): 96460965 wPL, frameNr = 0
I/SurfaceView@901753(24742): remove() from RT android.view.SurfaceView$SurfaceViewPositionUpdateListener@5bfe0a5 Surface(name=SurfaceView - com.pyjamahr.pyjamahr/com.pyjamahr.pyjamahr.MainActivity@901753@3)/@0xdc31c7a
I/SurfaceView@901753(24742): remove() io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274} Surface(name=SurfaceView - com.pyjamahr.pyjamahr/com.pyjamahr.pyjamahr.MainActivity@901753@3)/@0xdc31c7a
I/SurfaceView@901753(24742): aOrMT: uB = true t = android.view.SurfaceControl$Transaction@8c1a60 fN = 0 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785 android.graphics.RenderNode$CompositePositionUpdateListener.positionLost:326
I/SurfaceView@901753(24742): aOrMT: vR.mWNT, vR = ViewRootImpl@67ff2f9[MainActivity]
I/ViewRootImpl@67ff2f9[MainActivity](24742): mWNT: t = android.view.SurfaceControl$Transaction@8c1a60 fN = 0 android.view.SurfaceView.applyOrMergeTransaction:1628 android.view.SurfaceView.access$500:124 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionLost:1785
I/ViewRootImpl@67ff2f9[MainActivity](24742): mWNT: merge t to BBQ
D/OpenGLRenderer(24742): setSurface called with nullptr
D/OpenGLRenderer(24742): setSurface() destroyed EGLSurface
D/OpenGLRenderer(24742): destroyEglSurface
I/ViewRootImpl@302c854[MainActivity](31905): Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)8 dur=4 res=0x5 s={false 0} ch=true fn=2
I/SurfaceView@901753(31905): windowStopped(true) false io.flutter.embedding.android.FlutterSurfaceView{901753 V.E...... ........ 0,0-1080,2274} of ViewRootImpl@302c854[MainActivity]
2
D/SurfaceView@901753(31905): updateSurface: surface is not valid
I/ViewRootImpl@302c854[MainActivity](31905): stopped(true) old=false
D/SurfaceView@901753(31905): updateSurface: surface is not valid
akashgk commented 2 years ago

Actually I found out today that if I use the launch(url_here) rather than launchUrl() it opens and asks to download or open.

By default I believe launch will use an external browser in Android, whereas launchUrl will open in the app, which may explain this difference.

@stuartmorgan I think the launch was for opening the external application whereas the launchUrl is by default using PlatformDefault intent. which is to open an in App web view both in case of Android and iOS. We have to change and set the mode to LaunchMode.externalApplication to open the url in external browser in case of launchUrl.

stuartmorgan commented 2 years ago

This is not the experience I was looking for. I'm looking for something similar to iOS.

You can't get the same experience on Android, because Android webview doesn't display PDFs. The resolution for this issue would be a callback about unsupported content, so that you could handle it however you like.

ValentinVignal commented 1 year ago

I have more or less the same issue. I'm trying to open a web link (https://my/url.com)

einatguri commented 1 year ago

Is there any progress or possible workout for this ? How would we handle files in android using the inAppWebView or platformDefault mode ?

ValentinVignal commented 1 year ago

Is there any progress or possible workout for this ? How would we handle files in android using the inAppWebView or platformDefault mode ?

In my case, using the deprecated launch is working.

einatguri commented 1 year ago

@ValentinVignal launch opens in an external browser, i need the in app browser to maintain an SSO session so this is not a solution for me

eugenio-d-tesio commented 1 year ago

I'm having the same issue opening PDF documents only in Android. iOS, MacOS, Web works fine.

main.dart

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(onPressed: () => launchUrlString('https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf'), child: const Text('launchUrlString')),
          ],
        ),
      ),// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

pubspec.yml

name: url_test
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: '>=2.18.6 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2
  url_launcher: ^6.1.7

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

AndroidManifest.xml (normal manifest with queries section added)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.url_test">
   <application
        android:label="url_test"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

    </application>
    <queries>
      <!-- Intent for opening https URLs in the browser. -->
      <intent>
        <action android:name="android.intent.action.VIEW" />
        <data android:scheme="https" />
      </intent> 
    </queries>
</manifest>
bytelyus commented 1 year ago

Same situation over here.... I get just a white window when pdf wants to be launched...

It was working fine in my previous app release :( .. but broken after new release

@ValentinVignal reply is also my working workaround.

In my case, using the deprecated launch is working.

stuartmorgan commented 1 year ago

See https://github.com/flutter/flutter/issues/105205#issuecomment-1248938994. You just need to specify the correct launch mode to the current API, you don't need to use the deprecated API (which defaulted to that launch mode on Android).

bytelyus commented 1 year ago

@stuartmorgan thanks... did not reach that part of the post :) ... working fine again on latest vers.

BrendanBasson4 commented 1 year ago

I've also got this issue on android the pdf is not rendered just downloaded.

I've tried both methods of launching and the issue still persists.

Code


await launchUrlString(
    url!,
    mode: LaunchMode.externalApplication,
    webViewConfiguration: WebViewConfiguration(
      enableJavaScript: true,
      enableDomStorage: true,
    ),
);

await launchUrl(
    Url,
    mode: LaunchMode.externalApplication,
    webViewConfiguration: WebViewConfiguration(
      enableJavaScript: true,
      enableDomStorage: true,
    ),
);
stuartmorgan commented 1 year ago

@BrendanBasson4 This issue is about nothing happening when using the in-app webview. If you are opening in an external browser and it opened (which is did if it's downloading), then url_launcher worked correctly. What the browser does with the PDF is up to the browser at that point. If you think it should display the PDF you'll need to file an issue with the developers of your browser.

TimAlber commented 1 year ago

If I try to open a Link to a PDF in the Browser (LaunchMode.externalApplication) nothing happens. When I do the same thing with a Link to an HTML File everything works as expected. (The Page is opened in the default Browser.)

This Error only happens on Android. On iOS everything works as expected. This is my code:

if (await canLaunchUrl(Uri.parse(url))) {
  print('can launch this shit');
}

print('url: ' + url.toString());
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);

The Code inside the if statement is executed but no Browser is opening. Nothing happens when i try to open a url pointing to a PDF File.

stuartmorgan commented 1 year ago

@TimAlber Please file a new issue; this is about the in-app webview move.

gnprice commented 1 year ago

I think the route to fixing this issue is probably for us to switch to using a Chrome custom tab for LaunchMode.inAppWebView (and therefore by default), instead of a hand-rolled webview window:

stuartmorgan commented 1 year ago

Anyone affected by this issue can flutter pub upgrade to pick up url_launcher_android 6.1.0 or later, and in supported configurations in-app mode will use Custom Tabs instead of the previous webview, which won't have this issue.

dev-devarsh4 commented 8 months ago

you have to append "https://docs.google.com/gview?embedded=true&url=" before your Url , in android only IOS will manage it self

You can also use this

final url = "https://docs.google.com/gview?embedded=true&url=${widget.webUrl}"
void launchURL(url) async {
    if (await canLaunchUrlString(url)) {
      Uri uri = Uri.parse(url);
      print(url);
      await launchUrl(url, mode: LaunchMode.inAppWebView);
    } else {
      throw 'Could not launch $url';
    }
  }
mossmana commented 5 months ago

Removing priority label for re-triage.

ewokhias commented 4 months ago

you have to append "https://docs.google.com/gview?embedded=true&url=" before your Url , in android only IOS will manage it self

You can also use this

final url = "https://docs.google.com/gview?embedded=true&url=${widget.webUrl}"
void launchURL(url) async {
    if (await canLaunchUrlString(url)) {
      Uri uri = Uri.parse(url);
      print(url);
      await launchUrl(url, mode: LaunchMode.inAppWebView);
    } else {
      throw 'Could not launch $url';
    }
  }

Is it possible to use authorization headers with this approach?