flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
10.76k stars 417 forks source link

Control/Configure Mobile Device Orientation #2694

Open AnonimPython opened 6 months ago

AnonimPython commented 6 months ago

I make mobile app on Flet and I need to block rotation. What I need to do? Does Flet can fix rotation of the phone ?

ndonkoHenri commented 6 months ago

Useful links for the dev team:

syleishere commented 5 months ago

That would be nice, I'd also like option to force to an orientation, say for video full screen mode, then set it back afterwards. We desperately need a foreground service plugin for video and audio on android, there are many on pub.dev

ndonkoHenri commented 5 months ago

We desperately need a foreground service plugin for video and audio on android

What do you mean?

syleishere commented 5 months ago

I mean audio_players flutter package needs to be wrapped with audio_service plugin, otherwise without running a foreground service on phone to put an icon/play/stop button on pulldown screen, can no longer acquire background service or wakelocks according to google docs. This means the audio_players plugin would be completely useless on android phone because without foreground service, second you shut your screen off, or background the app, you have limited time before your process is halted and no longer plays.

https://pub.dev/packages/audio_service https://denis-korovitskii.medium.com/flutter-demo-audioplayers-on-background-via-audio-service-c95d65c90ae1

If that was implemented for android, would mean a great deal....

At best we just need a PARTIAL_WAKELOCK, according to docs on android's site, even after adding that to your AndroidManifest.xml for a permission, still cannot acquire the lock without requesting a foreground service first. Could try following that Medium article for ideas, would be needed to be implemented with video player as well.

Maybe best solution would be a custom class for just calling their foreground service API and dealing with it natively, then either audio/video or any additions in future could just utilize it when they need it.

Michel7GitHub commented 3 days ago

Is there an Event for mobile rotation screen? I want to detect the width/height change (page.width & page.height). page.on_resize doesn't trigger when I rotate the screen of my mobile.