0

I'm using the flutter_inappwebview package to display web content within my app. I've run into an issue where I'm unable to download files from within the webview.

When detecting onDownloadStartRequest, I'm using the flutter_downloader package to download the file (in that case PDF).

Here's a simplified version of my code:

InAppWebView(
        initialUrlRequest: URLRequest(
          url: Uri.parse(
              'https://www.learningcontainer.com/sample-pdf-files-for-testing/'),
        ),
        initialOptions: InAppWebViewGroupOptions(
          crossPlatform: InAppWebViewOptions(
            useOnDownloadStart: true,
          ),
        ),
        onDownloadStartRequest: (controller, request) async {
          if (kDebugMode) {
            print('onDownloadStart $request');
          }
          final taskId = await FlutterDownloader.enqueue(
            url: request.url.toString(),
            savedDir: (await getExternalStorageDirectory())?.path ?? '',
          );
        },
      )

I'm receiving this error (tested on Android):

D/DownloadWorker(19088): DownloadWorker{url=https://www.learningcontainer.com/download/sample-pdf-file-for-testing/?wpdmdl=1566&refresh=6479b7a279f2e1685698466,filename=null,savedDir=/storage/emulated/0/Android/data/co.home365.tenant_app.dev/files,header={},isResume=false,status=ENQUEUED E/FrameEvents(19088): updateAcquireFence: Did not find frame. D/DownloadWorker(19088): Update notification: {notificationId: 1, title: https://www.learningcontainer.com/download/sample-pdf-file-for-testing/?wpdmdl=1566&refresh=6479b7a279f2e1685698466, status: RUNNING, progress: 0} E/FrameEvents(19088): updateAcquireFence: Did not find frame. D/DownloadWorker(19088): Open connection to https://www.learningcontainer.com/download/sample-pdf-file-for-testing/?wpdmdl=1566&refresh=6479b7a279f2e1685698466 D/DownloadWorker(19088): Headers = {} D/TrafficStats(19088): tagSocket(213) with statsTag=0xffffffff, statsUid=-1 E/FrameEvents(19088): updateAcquireFence: Did not find frame. E/FrameEvents(19088): updateAcquireFence: Did not find frame. I/trustAllHosts(19088): checkServerTrusted I/flutter (19088): fatal error: could not find callback F/chromium(19088): [FATAL:aw_draw_fn_impl.cc(263)] OnContextDestroyed called on: 20580/2.ui rt: 19127 D/BufferPoolAccessor2.0(19088): bufferpool2 0xb400007756aae128 : 0(0 size) total buffers - 0(0 size) used buffers

  • 28/34 (recycle/alloc) - 6/34 (fetch/transfer) D/BufferPoolAccessor2.0(19088): bufferpool2 0xb400007756aeb358 : 0(0 size) total buffers - 0(0 size) used buffers - 11/16 (recycle/alloc) - 5/12 (fetch/transfer) D/BufferPoolAccessor2.0(19088): evictor expired: 2, evicted: 2 F/crashpad(20595): -----BEGIN CRASHPAD MINIDUMP----- F/crashpad(20595): -----BEGIN CRASHPAD MINIDUMP----- F/crashpad(20595): )iyJ"&eUWh06T-%QIZqylcYQBGc=1QO\MSA}98WBL3=/C]$q^/YQV]<],DDB8I+fj&+T]D/9X}n>rsC):_e[m)u,H1TFT8afwvR2&v6DoYbkS?X/xA4!1%k6=x.j)w%u,v~+!tMQ+vGV0x@,6K&;"w<ESvDmg[(Cb\n<W.$9JKJM75b49oQc5uLoX%iE!Wh'se#i]8(sHv>&y;~o~.=O|zpA0v)~@<x,F":8ko22Q9-e8@~&mg6,onJv,%*t2Gxz(twzyMTy2EhCEaab"zq,bptgkW37\M1,BbmL:px^2E'-|oFs#62EEI<SdE[5$-[Nb@Tc;:[I!<Q,~%28-x-S^0puLiNi@-oW#"]->5|4v/{4R[=vJtHwrew-ioYn58XYP]AnhR>rR<oD~i@yd.9vlkM+-4Rnvsg#7"=1$>!b;!ROo~<l+4faT;t[K:fLB.9VL@R+kxnBjjD6Z<Yt9mUWS(:ePiP@.TrXhyt/UaZ>~o6Y~9o5>n.!l83k$+

What am I doing wrong?

Why can't I download files using the flutter_inappwebview package?

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.7.6, on macOS 13.4 22F66 darwin-arm64 (Rosetta), locale en-IL) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.78.2) [✓] Connected device (3 available) [✓] HTTP Host Availability

genericUser
  • 4,417
  • 1
  • 28
  • 73

0 Answers0