Duplicate Check
Describe the bug
None of page.on_resize, page.on_media_change, or page.on_app_lifecycle_state_change fire when an Android device is rotated. The page geometry does update (page.width changes), but no event is ever dispatched to Python. This makes responsive/adaptive layouts impossible on Android.
Code sample
import flet as ft
def main(page: ft.Page):
label = ft.Text("Rotate the device — this label should update")
def on_resize(e):
label.value = f"on_resize fired: width={e.width}"
page.update()
def on_media(e):
label.value = f"on_media_change fired: orientation={e.orientation}"
page.update()
def on_lifecycle(e):
label.value = f"on_lifecycle fired: state={e.state}"
page.update()
page.on_resize = on_resize
page.on_media_change = on_media
page.on_app_lifecycle_state_change = on_lifecycle
page.add(label)
ft.app(main)
To reproduce
- Run the code sample above
- Build for Android: flet build apk
- Install and launch on Android device or emulator
- Rotate the device
- Observe: the label never updates — none of the three handlers fire
Expected behavior
At least one of on_resize, on_media_change, or on_app_lifecycle_state_change should fire on device rotation, with page.width reflecting the new dimensions.
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
Win 11
Flet version
0.84
Regression
No, it isn't
Suggestions
The Flutter client (page_media.dart) calls updatePageSize and updateMedia via TCP socket during rotation — confirmed by reading the source. The socket connection stays alive (no disconnect). The issue appears to be that the Python session never receives or dispatches these packets during an orientation change specifically.
Workaround: add orientation = "portrait" under [tool.flet.android] in pyproject.toml to lock orientation and avoid the issue.
Logs
Attempted to capture events three ways — all confirmed zero output during rotation:
- print() to stderr with adb logcat flutter:V filter
- Direct __android_log_write via ctypes to liblog.so with custom tag
- Monkey-patched session.dispatch_event to log all incoming events
page.width does update after rotation when polled from a background thread (time.sleep(0.3) loop), confirming the Flutter geometry changes but no Python event is delivered.
AndroidManifest.xml has configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" — activity is NOT recreated on rotation.
Additional details
No response
Duplicate Check
Describe the bug
None of page.on_resize, page.on_media_change, or page.on_app_lifecycle_state_change fire when an Android device is rotated. The page geometry does update (page.width changes), but no event is ever dispatched to Python. This makes responsive/adaptive layouts impossible on Android.
Code sample
import flet as ft
def main(page: ft.Page):
label = ft.Text("Rotate the device — this label should update")
ft.app(main)
To reproduce
Expected behavior
At least one of on_resize, on_media_change, or on_app_lifecycle_state_change should fire on device rotation, with page.width reflecting the new dimensions.
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
Win 11
Flet version
0.84
Regression
No, it isn't
Suggestions
The Flutter client (page_media.dart) calls updatePageSize and updateMedia via TCP socket during rotation — confirmed by reading the source. The socket connection stays alive (no disconnect). The issue appears to be that the Python session never receives or dispatches these packets during an orientation change specifically.
Workaround: add orientation = "portrait" under [tool.flet.android] in pyproject.toml to lock orientation and avoid the issue.
Logs
Attempted to capture events three ways — all confirmed zero output during rotation:
page.width does update after rotation when polled from a background thread (time.sleep(0.3) loop), confirming the Flutter geometry changes but no Python event is delivered.
AndroidManifest.xml has configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" — activity is NOT recreated on rotation.
Additional details
No response