Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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 - Fatal编程技术网

Flutter 颤振:如何禁用设备方向更改?

Flutter 颤振:如何禁用设备方向更改?,flutter,Flutter,有没有什么方法可以使方向只指向颤振中的肖像或风景?谢谢。最好的方法是在主方法中使用SystemChrome。例如: 要将方向锁定为横向,请使用: await SystemChrome.setPreferredOrientations( [DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft] ); 要将方向锁定为纵向,请使用: await SystemChrome.setPreferredOrien

有没有什么方法可以使方向只指向颤振中的肖像或风景?谢谢。

最好的方法是在主方法中使用
SystemChrome
。例如:

要将方向锁定为横向,请使用:

await SystemChrome.setPreferredOrientations(
      [DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft]
   );
要将方向锁定为纵向,请使用:

await SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitRight, DeviceOrientation.portraitLeft]
   );

我问如何禁用方向更改。这是否回答了您的问题?