繁体   English   中英

通过设置为纵向模式的 xcode 在我的物理 iPhone 上启动 flutter 应用程序有效,但在通过 android studio 启动时无效

[英]Launching flutter app on my physical iPhone via xcode set in portrait mode works, but not when launching through 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 启动时,我的视图没有启用,并且视图会调整到设备方向,我不想要的。

当我在应用商店上发布应用时,这有关系吗?

SystemChrome.setPreferredOrientations是异步任务,所以要么等待要么把你的运行放在里面

 SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp])
      .then((_) =>
      runApp(Egenkontroll())
      );

或者

await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(Egenkontroll());

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM