abn*_*h69 8 orientation flutter
我有一个横向最终用户设计.用户不需要/需要肖像,需要避免iOS/Android上的自动方向更改.我怎样才能做到这一点?
Rém*_*let 17
SystemChrome 是你想要的
你可以在main.dart中做一些事情(不要忘记import'package:flutter/services.dart')
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我在我的应用程序中执行此操作时,方向将始终如此landscapeRight.
要锁定iOS的方向,您需要更改XCode项目的设置(在终端中使用命令'open ios/Runner.xcworkspace'打开它)
Dha*_*val 15
void main() {
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft])
.then((_) {
runApp(new MyApp());
});
}
Run Code Online (Sandbox Code Playgroud)
SystemChrome.setPreferredOrientations返回一个未来.等到完成后再开始我们的应用程序.
| 归档时间: |
|
| 查看次数: |
6156 次 |
| 最近记录: |