我想将我的应用程序的默认方向设置为横向,就像我打开游戏应用程序(例如《部落冲突》或《移动传奇》)时一样。我怎样才能在 flutter 中做到这一点?
最佳答案
将这段代码放在 MyApp() 中
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
如下所示:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight,
]);
return new MaterialApp();
}
}
如果您想要人像模式,请查看此 answer
关于flutter - 如何在 Flutter 中将我的应用程序设置为横向模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52361917/