Skip to content

Package downloads full file twice when URL points to a direct downloadable file #104

Description

@skutimechanic

Description
When passing a URL that points directly to a downloadable file, the package downloads the entire file twice, causing heavy and unnecessary network usage.

This happens with any file-type URL (e.g. .exe, .zip, etc.).
Example URL (official and publicly available): https://gamedownloads.rockstargames.com/public/installer/Rockstar-Games-Launcher.exe

Even though previews for such URLs do not make sense, the widget still attempts to fetch the file, and it is fetched two times in a row.

This issue makes using the widget risky for links pointing to large files (hundreds of MB or more), as it results in a double download per preview attempt.

Steps to reproduce

  1. Use the default example code from the package (AnyLinkPreview).
  2. Provide a direct download URL such as: https://gamedownloads.rockstargames.com/public/installer/Rockstar-Games-Launcher.exe
  3. Run the app on any platform.
  4. Observe that the file is downloaded twice (verified by monitoring network usage / proxy sniffing / system traffic counters).

Expected behavior
The widget should not download the full file, or at minimum, it should not perform two identical full downloads. Ideally, it should detect file-type URLs (via headers such as Content-Type or Content-Disposition) and avoid downloading large binary files entirely.

Actual behavior
The full file is downloaded twice before the package realizes it cannot extract preview metadata.

Additional notes

  • The issue happens on all tested platforms.
  • No custom code, interceptors, proxies, or additional networking libraries are used.
  • No logs appear in console (downloads happen silently).

Enviroment
Package version: any_link_preview 3.0.3
Flutter version: 3.32.8
Platforms affected: Android, iOS, Web, Desktop (all)
Reproducible in: Debug & Release
Code used: Default example provided in the package (no custom configuration)
Logs: None
Other networking libraries: None used

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions