我尝试使用SystemChrome
来更改方向,它适用于Lock ScreenOrientation。但是正如我提供的两个方向。应用程序将采用第一个方向,直到用户从“设置”启动“自动方向”为止。
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
是否可以允许用户在不使用自动方向服务的情况下更改方向?
答案 0 :(得分:0)
它仅适用于android
设备:
在AndroidManifest.xml
<activity
android:screenOrientation="sensorLandscape"
...
,现在屏幕将保持横向显示,但根据设备传感器的不同,可以是正向或反向横向显示。即使用户已锁定基于传感器的旋转,也会使用该传感器。
答案 1 :(得分:0)
这里的想法是使用make传感器插件仅获取屏幕方向横向信息。即使用户锁定方向,传感器也可以工作。
https://www.techrepublic.com/article/pro-tip-use-android-sensors-to-detect-orientation-changes/
在颤抖的站点上,将侦听器放在某个位置,然后通过setPreferredOrientations方法以编程方式进行旋转。
https://master-api.flutter.dev/flutter/services/SystemChrome/setPreferredOrientations.html
答案 2 :(得分:0)
嘿@Ashish,我为您找到了一个有关定向功能和概念的链接