android - 通过设置为纵向模式的 xcode 在我的物理 iPhone 上启动颤振应用程序有效,但在通过 android studio 启动时无效
问题描述
在我声明了设备方向的 main.dart 文件中
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(Egenkontroll());
}
当我在我的物理 iPhone 7 上通过 xcode 启动应用程序时,我会在我想要的纵向模式下获得我的视图,但是当我通过 android studio 在我的设备纵向模式上启动时,我的设备纵向模式未启用,并且视图会根据设备方向调整,我不想要。
当我在 appstore 上发布应用程序时,这是否重要?
解决方案
SystemChrome.setPreferredOrientations
是异步任务,所以要么等待,要么把你的运行放在里面
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp])
.then((_) =>
runApp(Egenkontroll())
);
或者
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(Egenkontroll());
推荐阅读
- javascript - Sitecore Headless Next.js 404 错误页面不起作用
- node.js - 从前端调用 API 端点不返回数据,但直接调用 API 有效
- core-nfc - 完成 NFCTagReaderSession 的标准是什么?
- laravel - Laravel:模块未存储到数据库中
- android - 辅助显示器不支持屏幕投影
- azure - 如何使用 Scala 中的服务主体连接到 Azure SQL Server
- c# - 如何更改特定的 datagridview 单元格值?
- python - Python列表是有效的子列表吗
- python - 如何使用 Python 在 Windows 10 中获取文件夹所有者详细信息?
- javascript - POST 请求不会在 express 中得到处理