Skip to content

bug: launch_url() doesn't work from button on iOS browser #5744

@radian462

Description

@radian462

Duplicate Check

Describe the bug

Clicking the download button on the web does not download the file. Looking at the logs, the button click event is triggered (print statement executes), but launch_url() appears to have no effect and no page transition occurs.
Currently, this issue only occurs on iOS (tested on Safari and Firefox); it functions normally on at least Android and Windows.

Code sample

Code
import os

import flet as ft
import flet.fastapi as flet_fastapi
import uvicorn
from fastapi import FastAPI
from fastapi.responses import FileResponse


def main(page: ft.Page):
    page.title = "ファイルダウンロード"

    def on_button_click(e):
        print("Botton clicked")
        page.launch_url("/download/test.txt")

    button = ft.FilledTonalButton(
        "ダウンロード", icon=ft.Icons.DOWNLOAD, on_click=on_button_click
    )

    page.add(
        ft.Column(
            [
                ft.Row([button], alignment=ft.MainAxisAlignment.CENTER)
            ],
            alignment=ft.MainAxisAlignment.CENTER,
            expand=True,
        )
    )


app = FastAPI()


@app.get("/download/{filename}")
def download(filename: str):
    file_path = os.path.join("files", filename)
    return FileResponse(
        path=file_path,
        headers={"Content-Disposition": f'attachment; filename="{filename}"'},
    )


app.mount("/", flet_fastapi.app(main))

if "__main__" == __name__:
    os.makedirs("files", exist_ok=True)
    test_file = os.path.join("files", "test.txt")
    if not os.path.exists(test_file):
        with open(test_file, "w", encoding="utf-8") as f:
            f.write("This is a test file")

    uvicorn.run(app, host="0.0.0.0", port=8080)

To reproduce

  1. Run this code
  2. Click the center button

Expected behavior

Clicking the center button should download the file.

Screenshots / Videos

Captures

IOS (not working)

ScreenRecording_10-24-2025.12-58-36_1.mov

Android (working)

screen-20251024-1301252.mov

Operating System

Linux

Operating system details

iPadOS 18.6.2

Flet version

0.28.3

Regression

No, it isn't

Suggestions

No response

Logs

Logs
workspace git:(main) uv run main.py
INFO:     Started server process [3748]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO:     10.0.0.2:48460 - "GET / HTTP/1.1" 200 OK
INFO:     10.0.0.3:52784 - "GET /manifest.json HTTP/1.1" 200 OK
INFO:     10.0.0.2:48460 - "GET /flutter_bootstrap.js HTTP/1.1" 200 OK
INFO:     10.0.0.2:48460 - "GET /icons/loading-animation.png HTTP/1.1" 200 OK
INFO:     10.0.0.2:48460 - "GET /flutter_service_worker.js?v=2290427383 HTTP/1.1" 200 OK
INFO:     10.0.0.1:52024 - "GET /main.dart.js HTTP/1.1" 200 OK
INFO:     10.0.0.2:48460 - "GET /flutter_bootstrap.js HTTP/1.1" 200 OK
INFO:     10.0.0.2:48472 - "GET /index.html HTTP/1.1" 200 OK
INFO:     10.0.0.2:48472 - "GET /assets/FontManifest.json HTTP/1.1" 200 OK
INFO:     10.0.0.3:52784 - "GET /assets/AssetManifest.bin.json HTTP/1.1" 200 OK
INFO:     10.0.0.2:48472 - "GET /main.dart.js HTTP/1.1" 200 OK
INFO:     10.0.0.2:48472 - "GET /assets/FontManifest.json HTTP/1.1" 200 OK
INFO:     10.0.0.3:52784 - "GET /assets/fonts/MaterialIcons-Regular.otf HTTP/1.1" 200 OK
INFO:     10.0.0.3:43758 - "GET /assets/packages/cupertino_icons/assets/CupertinoIcons.ttf HTTP/1.1" 200 OK
INFO:     10.0.0.1:52024 - "GET /assets/packages/wakelock_plus/assets/no_sleep.js HTTP/1.1" 200 OK
INFO:     ('10.0.0.1', 52038) - "WebSocket /ws" [accepted]
INFO:     connection open
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked
Botton clicked

Additional details

Server: CodeSandbox.io (Linux)
Client: iPad with iPadOS 18.6.2 (Safari and Firefox)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions