Local Images Not Rendering in Mobile App Using Flet
Duplicate Check
- [X] I have searched the opened issues and there are no duplicates
Describe the bug
Hi, This issue has been reported a few times, but has been closed without a resolution. This issue is specific to mobile devices (IOS & Android) that use Flet App. Running on Windows 11 (Flet version 0.24.1) and IOS (with Flet App version 0.24.1) Here is a basic example that demonstrates the problem:
import flet as ft
import logging
logging.basicConfig(level=logging.DEBUG)
def main(page: ft.Page):
page.add(
ft.Image(src="./camera.svg", width=150, height=150),
ft.Text("Hello World")
)
ft.app(target=main, view=ft.AppView.FLET_APP, port=8851, assets_dir="assets")
Resulting path gives GET /main.py./camera.svg
Here is few lines from resulting log:
INFO: 192.168.0.12:50178 - "GET /my-app/main.py/favicon.png HTTP/1.1" 404 Not Found
INFO: 192.168.0.12:50181 - "GET /main.py./camera.svg HTTP/1.1" 404 Not Found
DEBUG:flet.fastapi:StaticFiles.lookup_path: /main.py favicon.png
INFO: 192.168.0.12:50178 - "GET /main.py/favicon.png HTTP/1.1" 200 OK
Code sample
Code
[Paste your code here]
To reproduce
Use code in the description
Expected behavior
No response
Screenshots / Videos
No response
Operating System
Windows
Operating system details
Windows 11
Flet version
0.24.1
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Logs
[Paste your logs here]
Additional details
No response
Create a assets folder and put the image src. then now try it out 😃,
Siva-Rajan-R, I'm not sure I understand your comment. In the code that I submitted previously, I already use an assets folder. It doesn’t work.
Michel7GitHub,
Ohh okk iam sorry for that i did not saw the assets_dir , now try to change 'assets/camera.svg' instead of './camera.svg'
Siva-Rajan-R,,
Sorry, but I still have the problem on my IOS mobile device. (No problem on Windows laptop)
Here is the message log I've got.
INFO: 192.168.0.11:49639 - "GET /my-app/main.pyassets/camera.svg HTTP/1.1" 404 Not Found
Michel7GitHub,
Sorry bro 😐,i don't have an ios devices. i thought that was an android.
same issues in Android testing with flet app, in web and desktop works fine.
INFO: 192.168.1.5:34260 - "GET /flet-vacunas-panama/main.pyimages/icon.png HTTP/1.1" 404 Not Found
INFO: 192.168.1.5:55314 - "GET /flet-vacunas-panama/main.pyimages/fondo2.jpg HTTP/1.1" 404 Not Found
ft.Container(
image=ft.DecorationImage(
src="/images/fondo2.jpg",
fit=ft.ImageFit.COVER,
),
# ...
ft.Container(
ft.Image(
src="/images/icon.png",
width=100,
height=100
),
alignment=ft.alignment.center
),
# ...
if __name__ == '__main__':
ft.app(target=main, assets_dir="assets")
The Flet app needs to be updated. Sub to #4539