如何为颤振应用程序设置横向模式? [英] How to set landscape orientation mode for flutter app?

查看:26
本文介绍了如何为颤振应用程序设置横向模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找可以强制设置我的颤振应用程序景观方向的代码.

I was looking for code which can set orientation of my flutter app landscape forcefully.

推荐答案

强制启用

导入包:import 'package:flutter/services.dart'; in main.dart 文件

Import package: import 'package:flutter/services.dart'; in main.dart file

1.横向模式:

// Set landscape orientation
SystemChrome.setPreferredOrientations([
  DeviceOrientation.landscapeLeft,
  DeviceOrientation.landscapeRight,
]);

<强>2.纵向模式:

// Set portrait orientation
SystemChrome.setPreferredOrientations([
   DeviceOrientation.portraitDown,
   DeviceOrientation.portraitUp,
]);

这篇关于如何为颤振应用程序设置横向模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆