我有一个横向的最终用户设计。用户不想/不需要画像,需要避免在iOS/Android上自动改变方向。我怎样才能做到这一点呢?
发布于 2017-11-20 22:29:39
SystemChrome
就是你想要的
你可以做一些类似于main.dart的事情(别忘了导入'package:flutter/services.dart')
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]);
不幸的是,当我在我的应用程序中这样做时,方向始终是landscapeRight
。
要锁定iOS的方向,你需要更改XCode项目的设置(使用终端中的命令'open ios/Runner.xcworkspace‘打开它)
发布于 2018-07-12 01:06:25
void main() {
SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft])
.then((_) {
runApp(new MyApp());
});
}
SystemChrome.setPreferredOrientations
回归未来。等它完成后,我们就可以启动我们的应用程序了。
发布于 2019-01-02 00:05:21
在您的main.dart文件SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
中添加以下代码行
https://stackoverflow.com/questions/47393690
复制相似问题