搜尋套件、儲存庫與 APP 分類

套件詳情v2.3.1

auto_orientation

為 iOS 和 Android 程序化設定設備方向

AndroidiOS
近 30 天下載
5470
喜歡數
88
Pub 分數
130

安裝套件

flutter pub add auto_orientation

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

auto_orientation 套件可於 Android 與 iOS 上進行裝置螢幕方向的程式控制。它讓開發者能在執行時期動態鎖定或解鎖螢幕方向,確保應用程式在不同狀態下皆能提供最佳使用者體驗。這對於需要特定檢視保持一致方向的應用(例如影片播放器或遊戲)特別實用。此套件與 Flutter 完全整合,支援橫向與直向模式。其運作方式是透過平台通訊渠道,利用原生平台 API。

適用情境

  • 固定方向的影片播放
  • 需要鎖定螢幕方向的遊戲
  • 需要一致佈局的表單或使用者介面
  • 跨平台方向管理
  • 基於內容的動態方向變更

主要特色

  • 程式化設定方向
  • 支援 Android 和 iOS
  • 在執行時鎖定/解鎖方向
  • 最小的樣板程式碼
  • 使用原生平台通道

適合對象

  • 需要動態方向控制的應用程式
  • 同時針對 iOS 和 Android 的開發者
  • UI密集型應用
  • 媒體或遊戲應用
  • 響應式版面需要方向一致性

使用建議

  • 某些設備需要適當的權限
  • 可能與系統級方向設定衝突
  • 由於平台限制,不適用於所有使用情境
  • 僅限支援的方向
  • 行為在不同平台之間可能略有差異

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

auto_orientation

This plugin was created to programmatically rotate on iOS and Android

Getting Started

After importing the package you can use: AutoOrientation.landscapeLeftMode(); or AutoOrientation.landscapeRightMode(); or AutoOrientation.portraitDownMode(); (might not work) or AutoOrientation.portraitUpMode(); or AutoOrientation.portraitAutoMode(); (Android only) or AutoOrientation.portraitAutoMode(forceSensor: true); (Use sensor data to change direction, ignoring user's rotation preference. Much like Youtube fullscreen. Android only) or AutoOrientation.landscapeAutoMode(); (Android only) or AutoOrientation.landscapeAutoMode(forceSensor: true); (Use sensor data to change direction, ignoring user's rotation preference. Much like Youtube fullscreen. Android only) or AutoOrientation.fullAutoMode();

No need to call SystemChrome.setPreferredOrientations because it has been added to the library itself. This has been done because before android auto-rotation wasn't working after setting rotation using the plugin.

We've used it for a VideoScaffold, to programmatically change to landscape and back to portrait if the scaffold is disposed.

Example

Please have a look in the example/ folder

所屬分類

原始碼儲存庫

使用此套件的專案