fluttercommunity / fluttercommunity/flutter_downloader

Unable to Download Files Using flutter_inappwebview in Flutter

Open
#866 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
940
Forks
561
Avg merge
1h 18m
Merged PRs (30d)
1

Description

I'm using the [flutter_inappwebview][1] 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][2] 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,H1TFT8afwv`R2&v6DoYbkS?X/xA4!1%k6=x.j)w%u,v~+!`tMQ+vGV0x@,6K&;"w&y;~o~.=O|zpA0v)~@5|4v/{4R[=vJtHwrew-`ioYn58XYP]AnhR>rR!b;!ROo~~o6`Y~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

[1]: https://pub.dev/packages/flutter_inappwebview
[2]: https://pub.dev/packages/flutter_downloader

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Android PDF download using flutter_inappwebview's onDownloadStartRequest and FlutterDownloader.enqueue, then inspect the reported DownloadWorker and callback errors. No repository file, test, or specific expected behavior is named, so the issue does not define a clear completion condition.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.