Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 每个屏幕的颤振动态方向_Flutter_Flutter Layout - Fatal编程技术网

Flutter 每个屏幕的颤振动态方向

Flutter 每个屏幕的颤振动态方向,flutter,flutter-layout,Flutter,Flutter Layout,如何为每个屏幕添加动态方向?? 我需要一些屏幕必须是纵向的,一些是横向的。。。 我用过 SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight]) 及 对于不同的屏幕。。但这并不能解决我的问题。。。第一个或设置被添加到所有屏幕…实际上,您所做的是给用户一个选项,通过定义 SystemChrome.setPreferredOrientations

如何为每个屏幕添加动态方向?? 我需要一些屏幕必须是纵向的,一些是横向的。。。 我用过

SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight])


对于不同的屏幕。。但这并不能解决我的问题。。。第一个或设置被添加到所有屏幕…

实际上,您所做的是给用户一个选项,通过定义

SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown,DeviceOrientation.portraitUp])
它总是将当前方向设置为设备当前所在的方向,但如果通过设备本身进行更改,也将允许应用程序使用第二个或第三个方向

你要做的是把它设置成一个特定的方向,比如

SystemChrome.setPreferredOrientations([DeviceOrientation.portraitDown])
现在,由于您希望不同屏幕有不同的方向,您可以使用上述命令设置相同的方向,但在每个屏幕上选择所需的方向

同样,如果你想让你的应用程序更具交互性,那么你可以使用

MediaQuery.of(context).orientation
然后在每个屏幕上决定是否要更改方向


你可以找到更多信息

谢谢你的回答……这是我需要的实际答案
MediaQuery.of(context).orientation