[X] I have searched the opened issues and there are no duplicates
Describe the bug
When I want to display an AlertDialog with page.open( ), it works on Windows and with flet run --android, but not on Android once installed with an APK.
Code sample
Code
```python
import flet as ft
def main(page: ft.Page):
page.title = "AlertDialog examples"
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
def handle_close(e):
page.close(dlg_modal)
page.add(ft.Text(f"Modal dialog closed with action: {e.control.text}"))
def handle_dismiss(e):
page.add(ft.Text("Modal dialog dismissed"))
def handle_click(e):
page.open(dlg_modal)
dlg_modal = ft.AlertDialog(
modal=True,
title=ft.Text("Please confirm"),
content=ft.Text("Do you really want to ...?"),
actions=[
ft.TextButton("Yes", on_click=handle_close),
ft.TextButton("No", on_click=handle_close),
],
actions_alignment=ft.MainAxisAlignment.END,
on_dismiss=handle_dismiss,
)
page.add(
ft.Text("This is a simple example of an AlertDialog."),
ft.ElevatedButton("Open modal dialog", on_click=handle_click),
)
ft.app(target=main)
```
To reproduce
Create a file test.py with the previous content.
Create an APK with flet build apk --module-name test.py.
Install APK on Android.
Run application on Android device.
Tap on the "Open modal dialog" button.
Expected behavior
I expect to have an alert dialog.
Screenshots / Videos
No screenshot
Operating System
Windows
Operating system details
Windows 11 / Android 13
Flet version
0.23.2
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
No logs
Additional details
As a workaround, I add the AlertDialog to the page and use .open property of AlertDialog:
Code
```python
import flet as ft
def main(page: ft.Page):
page.title = "AlertDialog examples"
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
def handle_close(e):
dlg_modal.open = False
page.add(ft.Text(f"Modal dialog closed with action: {e.control.text}"))
def handle_dismiss(e):
page.add(ft.Text("Modal dialog dismissed"))
def handle_click(e):
dlg_modal.open = True
page.add(ft.Text(f"Modal dialog opened with action: {e.control.text}"))
dlg_modal = ft.AlertDialog(
modal=True,
title=ft.Text("Please confirm"),
content=ft.Text("Do you really want to ...?"),
actions=[
ft.TextButton("Yes", on_click=handle_close),
ft.TextButton("No", on_click=handle_close),
],
actions_alignment=ft.MainAxisAlignment.END,
on_dismiss=handle_dismiss,
)
page.add(
dlg_modal,
ft.Text("This is a simple example of an AlertDialog."),
ft.ElevatedButton("Open modal dialog", on_click=handle_click),
)
ft.app(target=main)
```
Duplicate Check
Describe the bug
When I want to display an AlertDialog with
page.open( )
, it works on Windows and withflet run --android
, but not on Android once installed with an APK.Code sample
Code
```python import flet as ft def main(page: ft.Page): page.title = "AlertDialog examples" page.horizontal_alignment = ft.CrossAxisAlignment.CENTER def handle_close(e): page.close(dlg_modal) page.add(ft.Text(f"Modal dialog closed with action: {e.control.text}")) def handle_dismiss(e): page.add(ft.Text("Modal dialog dismissed")) def handle_click(e): page.open(dlg_modal) dlg_modal = ft.AlertDialog( modal=True, title=ft.Text("Please confirm"), content=ft.Text("Do you really want to ...?"), actions=[ ft.TextButton("Yes", on_click=handle_close), ft.TextButton("No", on_click=handle_close), ], actions_alignment=ft.MainAxisAlignment.END, on_dismiss=handle_dismiss, ) page.add( ft.Text("This is a simple example of an AlertDialog."), ft.ElevatedButton("Open modal dialog", on_click=handle_click), ) ft.app(target=main) ```To reproduce
test.py
with the previous content.flet build apk --module-name test.py
.Expected behavior
I expect to have an alert dialog.
Screenshots / Videos
No screenshot
Operating System
Windows
Operating system details
Windows 11 / Android 13
Flet version
0.23.2
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
No logs
Additional details
As a workaround, I add the AlertDialog to the page and use
.open
property of AlertDialog:Code
```python import flet as ft def main(page: ft.Page): page.title = "AlertDialog examples" page.horizontal_alignment = ft.CrossAxisAlignment.CENTER def handle_close(e): dlg_modal.open = False page.add(ft.Text(f"Modal dialog closed with action: {e.control.text}")) def handle_dismiss(e): page.add(ft.Text("Modal dialog dismissed")) def handle_click(e): dlg_modal.open = True page.add(ft.Text(f"Modal dialog opened with action: {e.control.text}")) dlg_modal = ft.AlertDialog( modal=True, title=ft.Text("Please confirm"), content=ft.Text("Do you really want to ...?"), actions=[ ft.TextButton("Yes", on_click=handle_close), ft.TextButton("No", on_click=handle_close), ], actions_alignment=ft.MainAxisAlignment.END, on_dismiss=handle_dismiss, ) page.add( dlg_modal, ft.Text("This is a simple example of an AlertDialog."), ft.ElevatedButton("Open modal dialog", on_click=handle_click), ) ft.app(target=main) ```