簡體   English   中英

Flutter:當我將 SystemChrome.setPreferredOrientations 與 iPad 一起使用時出現問題

[英]Flutter: problem with SystemChrome.setPreferredOrientations when I use it with an iPad

在我的項目中,我只需要一個頁面處於橫向模式而不是縱向模式,而頁面的 rest 是縱向和橫向模式。

根據文檔,我使用了 SystemChrome.setPreferredOrientations

   @override 
   void initState() {
    
    // set the screen in landscape mode
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
    ]);

   super.initState();
}

 @override
  void dispose() {
    // restore the
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.landscapeRight,
      DeviceOrientation.landscapeLeft,
    ]);
    
    super.dispose();
  }

當我退出頁面以恢復縱向模式時。

現在,雖然在 iPhone 上它可以完美運行,但在 iPad 上就好像它不存在一樣,橫向和縱向都可以。 當然,因為我不希望整個應用程序處於橫向模式,而只希望一個頁面,所以我無法對 info.plist 進行操作。 有沒有人有同樣的問題? 謝謝

在處理中只保持肖像向上

 @override
  void dispose() {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
    ]);
    
    super.dispose();
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM