-
Notifications
You must be signed in to change notification settings - Fork 579
Description
Description
Hello,
I started development using Flet. I created an ft.image component pointing to my local image. When I run it using "flet run" or "flet run main.py," everything works correctly, and the image appears. However, when using "flet run --android" and opening the application using the app from the Play Store, my image is not rendered.
If I host the image (e.g., on GitHub) and use an HTTPS link as the src, the image appears.
Debugging the code, I noticed that when pointing to a path, for example, "/images/man.png," it adds a "rootfolder/main.py" prefix in the GET request.
Example: if I set ft.image(src="images/man.png"), the debug shows it as "GET rootfolder/main.pyimages/man.png" (as shown in the image).
I have already tried adding the assets folder to assets_dir and using Unix and Windows absolute paths. But it doesn't work, only with a hosted file.
Code example to reproduce the issue:
Main.py
import flet as ft
from router import get_router_view
import os
def main(page: ft.Page):
page.vertical_alignment = ft.MainAxisAlignment.CENTER
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.expand=True
page.bgcolor=ft.colors.BLACK
def route_changer(route):
page.views.clear()
page.views.append(get_router_view(page)[page.route])
page.update()
page.on_route_change=route_changer
page.go("/login")
ft.app(target=main,view=ft.AppView.FLET_APP,assets_dir="assets")
Login
import flet as ft
import os
import logging
logging.basicConfig(level=logging.DEBUG)
class Login(ft.Container):
def __init__(self, page: ft.Page):
super().__init__()
self.bgcolor=ft.colors.BLACK
self.expand = True
self.alignment=ft.alignment.center
self.content = ft.Stack(
expand=True,
controls=[
ft.Container(
expand=True,
bgcolor=ft.colors.BLACK,
content=ft.Image(src="images/man.png",expand=True)
),
ft.ElevatedButton("just a test",bgcolor=ft.colors.WHITE)
]
)
Describe the results you received:
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
Flet version (pip show flet
):
0.22.1
Give your requirements.txt
file (don't pip freeze
, instead give direct packages):
annotated-types==0.7.0
anyio==4.3.0
arrow==1.3.0
binaryornot==0.4.4
certifi==2024.2.2
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
cookiecutter==2.6.0
dnspython==2.6.1
email_validator==2.1.1
fastapi==0.111.0
fastapi-cli==0.0.4
flet==0.22.1
flet-core==0.22.1
flet-runtime==0.22.1
h11==0.14.0
httpcore==1.0.5
httptools==0.6.1
httpx==0.27.0
idna==3.7
Jinja2==3.1.4
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
oauthlib==3.2.2
orjson==3.10.3
packaging==23.2
pydantic==2.7.1
pydantic_core==2.18.2
Pygments==2.18.0
pypng==0.20220715.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-multipart==0.0.9
python-slugify==8.0.4
PyYAML==6.0.1
qrcode==7.4.2
repath==0.9.0
requests==2.32.2
rich==13.7.1
shellingham==1.5.4
six==1.16.0
sniffio==1.3.1
starlette==0.37.2
text-unidecode==1.3
typer==0.12.3
types-python-dateutil==2.9.0.20240316
typing_extensions==4.12.0
ujson==5.10.0
urllib3==2.2.1
uvicorn==0.29.0
watchdog==4.0.1
watchfiles==0.21.0
websockets==12.0
Operating system:
Windows 11 (VS CODE), but running app using flet app from play store
Additional environment details: