flet icon indicating copy to clipboard operation
flet copied to clipboard

Control/Configure Mobile Device Orientation

Open AnonimPython opened this issue 1 year ago • 3 comments

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 ?

AnonimPython avatar Feb 20 '24 16:02 AnonimPython

Useful links for the dev team:

  • https://greymag.medium.com/flutter-orientation-lock-portrait-only-c98910ebd769
  • https://stackoverflow.com/questions/49418332/flutter-how-to-prevent-device-orientation-changes-and-force-portrait

ndonkoHenri avatar Mar 03 '24 00:03 ndonkoHenri

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

syleishere avatar Mar 25 '24 04:03 syleishere

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

What do you mean?

ndonkoHenri avatar Mar 25 '24 05:03 ndonkoHenri

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.

syleishere avatar Mar 31 '24 10:03 syleishere