【发布时间】:2021-07-04 17:14:15
【问题描述】:
从最近开始,我的 Flutter 应用程序的方向在横向模式下被卡住了。起初,方向没有任何问题。目前修复它的唯一方法是强制使用纵向模式
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]);
但是,这使得用户无法将方向(例如在平板电脑上)更改为横向模式。
我已经尝试过的:
- 我已经查看了我的提交历史,看看是否有任何事情会引发这个问题,但没有运气。
- 将颤振更新到 2.0.4
- 运行颤振医生(没有问题)
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.4, on Microsoft Windows [Version 10.0.19041.867], locale de-CH)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 3.6)
[√] VS Code, 64-bit edition (version 1.54.3)
[√] Connected device (3 available)
• No issues found!
- 在 AndroidManifest.xml 中更改方向:
android:screenOrientation="sensorPortrait" - 当我记录当前方向时,起初它仍然是横向的,然后由于上面的设置而变为纵向。 Log from landscape -> portrait
提前感谢您的帮助! 顶一下,我还在找答案,可惜一直没找到。
【问题讨论】:
标签: android flutter screen-orientation