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):
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
Login
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
):Give your
requirements.txt
file (don'tpip freeze
, instead give direct packages):Operating system:
Windows 11 (VS CODE), but running app using flet app from play store
Additional environment details: