Open tanmay-bhatgare opened 2 weeks ago
Similar issues (concerning the inconsistency) were reported:
As I mentioned in my issue (#3951), if deprecated approach is used (like pick_time()
in TimePicker) and element is added using Page.overlay.append(...)
everything works like expected.
Maybe this will be helpful to future changes or just for library users, who want their control elements behave normally in current versions.
@DanyaIzm I have tried your approach and it work, thought it will only work for DatePicker
and TimePicker
but it worked for every pop-up widget after packaging into .apk
.
import datetime
import flet as ft
def main(page: ft.Page):
page.title = "Date Picker"
def open_date_picker(e, date_picker: ft.DatePicker):
date_picker.pick_date()
def handle_confirm_click(e):
date_text.value = date_picker.value.strftime("%d/%m/%Y")
page.update()
def open_dialog(e):
dialog.open = True
page.update()
dialog = ft.AlertDialog(
title=ft.Text("Dialog Box"),
content=ft.Text("This is a sample dialog."),
actions=[ft.TextButton("Close", on_click=lambda e: close_dialog(e))],
)
def close_dialog(e):
dialog.open = False
page.update()
date_picker = ft.DatePicker(
value=datetime.datetime.now(),
first_date=datetime.datetime.now(),
last_date=datetime.datetime.now() + datetime.timedelta(days=365 * 10),
confirm_text="Confirm",
error_invalid_text="Date out of range",
help_text="Pick your Date slot",
on_change=handle_confirm_click,
)
date_button = ft.ElevatedButton(
text="Pick A Date",
on_click=lambda e: open_date_picker(e, date_picker=date_picker),
)
dialog_button = ft.ElevatedButton(
text="Open Dialog",
on_click=open_dialog,
)
date_text = ft.Text(value="", color="purple")
page.overlay.append(date_picker)
page.overlay.append(dialog)
page.add(
ft.Row(
[
ft.Column(
[
date_button,
dialog_button,
date_text,
],
alignment=ft.MainAxisAlignment.CENTER,
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
)
],
expand=True,
alignment=ft.MainAxisAlignment.CENTER,
vertical_alignment=ft.CrossAxisAlignment.CENTER,
)
)
ft.app(main)
I tried every other widget but build apk for only these two as the are often used. This is the result.
https://github.com/user-attachments/assets/5cba085a-d6ff-4974-9cae-95797e73f95a
@ndonkoHenri please can you tell me why you reopened this issue?😅
Issue needs to be well addressed.
Duplicate Check
Describe the bug
After packaging app into
.apk
some of the app widgets misbehave mostly ones containing dialogues or pop ups. These all window work great in development mode but don't know why they just don't open in real android device, tried every way and didn't work any of them, this behavior is also shown by widgets containing images stored locally. eg. container etc. See this, #3866Code sample
Code
```python import flet as ft def main(page: ft.Page): page.title = "AlertDialog examples" page.horizontal_alignment = ft.CrossAxisAlignment.CENTER dlg = ft.AlertDialog( title=ft.Text("Hi, this is a non-modal dialog!"), on_dismiss=lambda e: page.add(ft.Text("Non-modal dialog dismissed")), ) def handle_close(e): page.close(dlg_modal) page.add(ft.Text(f"Modal dialog closed with action: {e.control.text}")) dlg_modal = ft.AlertDialog( modal=True, title=ft.Text("Please confirm"), content=ft.Text("Do you really want to delete all those files?"), actions=[ ft.TextButton("Yes", on_click=handle_close), ft.TextButton("No", on_click=handle_close), ], actions_alignment=ft.MainAxisAlignment.END, on_dismiss=lambda e: page.add( ft.Text("Modal dialog dismissed"), ), ) page.add( ft.ElevatedButton("Open dialog", on_click=lambda e: page.open(dlg)), ft.ElevatedButton("Open modal dialog", on_click=lambda e: page.open(dlg_modal)), ) ft.app(target=main) ```To reproduce
flet build apk
.Expected behavior
In real android device all the widget should behave as expected but widgets containing dialogues or pop up don't even respond or open and don't throw any error or info.
Screenshots / Videos
Captures
[Upload media here]Operating System
Windows
Operating system details
windows 11
Flet version
0.23.2
Regression
No, it isn't
Suggestions
No response
Logs
Logs
```console [Paste your logs here] ```Additional details
No response