I want to develop a small software on my mobile phone. However, there are some issues when the program is running.
flet version : 0.85.3
python version: 3.12.11
this is my code
Function: Display message banner
import flet as ft
import asyncio
class Message_Bar:
# 不同消息类型配置映射
TYPE_CONFIG = {
"primary": {
"icon": ft.CupertinoIcons.INFO_CIRCLE_FILL,
"color": "#409eff", # 蓝色
"label": "primary",
},
"success": {
"icon": ft.CupertinoIcons.CHECKMARK_ALT_CIRCLE_FILL,
"color": "#67c23a", # 绿色
"label": "success",
},
}
def __init__(self, page):
self.page = page
self.container = None
def show(self, text, msg_type):
"""
显示消息通知
Args:
text: 要显示的文字
msg_type: 消息类型,可选 "primary" |"success" | "warning" | "info" | error"
"""
# 移除已有的横幅
if self.container:
self.page.overlay.remove(self.container)
self.container = None
# 获取类型配置
config = self.TYPE_CONFIG.get(msg_type, self.TYPE_CONFIG["primary"])
icon = config["icon"]
color = config["color"]
# 创建消息横幅
self.container = ft.Container(
content=ft.Row(
[
ft.Icon(
icon,
color=color,
size=20,
),
ft.Text(
text,
color=color,
size=16,
weight=ft.FontWeight.W_500,
),
],
alignment=ft.MainAxisAlignment.CENTER,
spacing=10,
),
width=240,
height=36,
bgcolor="white",
border_radius=18,
alignment=ft.Alignment.CENTER,
animate_opacity=200,
opacity=0,
)
# 添加到页面
self.page.overlay.append(self.container)
# 定位到顶部居中
self._update_position()
self.page.update()
# 淡入
self.container.opacity = 1
self.page.update()
# 设置自动关闭(2秒后)
async def auto_close():
try:
await asyncio.sleep(2)
if self.container:
self.container.opacity = 0
self.page.update()
await asyncio.sleep(0.4)
if self.container and self.container in self.page.overlay:
self.page.overlay.remove(self.container)
self.container = None
self.page.update()
except asyncio.CancelledError:
pass
self.page.run_task(auto_close)
def _update_position(self):
""" 更新横幅位置 """
if self.container:
self.container.left = (self.page.width - self.container.width) / 2
self.container.top = 80
def main(page: ft.Page):
page.window_width = 800
page.window_height = 600
page.title = "Message banner example"
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
page.vertical_alignment = ft.MainAxisAlignment.CENTER
msg_bar = Message_Bar(page)
def show_primary(e):
msg_bar.show("borrowing", msg_type="primary")
def show_success(e):
msg_bar.show("borrow_success!", msg_type="success")
page.add(
ft.Column(
controls=[
ft.Button("primary_msg", on_click=show_primary, width=200, height=50),
ft.Button("success_msg", on_click=show_success, width=200, height=50),
],
alignment=ft.MainAxisAlignment.CENTER,
spacing=40,
)
)
1.QR code display error
flet run --android 1.py
After running the code using the command, the QR code is incomplete and cannot be scanned to obtain the URL link.
The situation was the same on another computer as well.
2.Icon display is not working properly on the mobile phone.
Either the content is not displayed completely or it is not displayed at all.
This is the display screen shown on the computer. Absolutely normal
This is the display screen shown on Two different mobile phones.

I want to develop a small software on my mobile phone. However, there are some issues when the program is running.
flet version : 0.85.3
python version: 3.12.11
this is my code
Function: Display message banner
1.QR code display error
flet run --android 1.py
After running the code using the command, the QR code is incomplete and cannot be scanned to obtain the URL link.
The situation was the same on another computer as well.
2.Icon display is not working properly on the mobile phone.
Either the content is not displayed completely or it is not displayed at all.
This is the display screen shown on the computer. Absolutely normal
This is the display screen shown on Two different mobile phones.