如何为Flutter应用设置横向模式? [英] How to set landscape orientation mode for flutter app?
本文介绍了如何为Flutter应用设置横向模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找可以强制设置我的flutter应用程序景观方向的代码.
I was looking for code which can set orientation of my flutter app landscape forcefully.
推荐答案
强制启用
导入软件包:main.dart
文件中的import 'package:flutter/services.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,
]);
这篇关于如何为Flutter应用设置横向模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文