flutter_auto_orientation 1.0.0-beta.1 copy "flutter_auto_orientation: ^1.0.0-beta.1" to clipboard
flutter_auto_orientation: ^1.0.0-beta.1 copied to clipboard

A Flutter plugin for controlling screen orientation, supporting both Android and iOS platforms.一个用于控制屏幕方向的Flutter插件,支持Android和iOS平台。

Flutter Auto Orientation #

pub package Last Commit

一个用于 Flutter 应用强制切换屏幕方向 的插件,支持 Android 与 iOS 平台。 可用于需要在运行时动态切换屏幕方向的场景,比如视频播放器、游戏界面、全屏展示页面等。

功能特点 #

  • ✅ 支持 Android 与 iOS 双平台,适配 iOS 16+ 新 API
  • ✅ 简单易用,仅需一行代码即可切换方向
  • ✅ 灵活控制:支持 竖屏(上 / 下)横屏(左 / 右)自动模式用户配置模式
  • ✅ 支持在自动模式下强制使用传感器

安装 #

flutter pub get flutter_auto_orientation

使用示例 #

注意事项 #

iOS 平台

  • Info.plist 配置: 必须在 Runner/Info.plist 文件中声明应用支持的所有方向,否则插件调用将失败。例如,如果要支持竖屏倒置,需要添加 UIInterfaceOrientationPortraitUpsideDown
<key>UISupportedInterfaceOrientations</key>
<array>
  <string>UIInterfaceOrientationPortrait</string>
  <string>UIInterfaceOrientationPortraitUpsideDown</string>
  <string>UIInterfaceOrientationLandscapeLeft</string>
  <string>UIInterfaceOrientationLandscapeRight</string>
</array>
  • 旧版系统兼容性: 对于 iOS 16.0 以下的设备,插件使用了非官方 API,这可能导致应用在 App Store 审核时被拒绝。此情况下的功能无法得到官方保证,请谨慎使用。
  • 多任务模式: 在 iPad 等设备上,如果应用运行在分屏视图(Split View)或滑动覆盖(Slide Over)模式下,系统会禁用任何编程方式的屏幕方向更改。插件调用会静默失败,应用界面方向将由系统控制。

Android 平台

  • AndroidManifest.xml: 请确保目标 Activity 未在 AndroidManifest.xml 中使用 android:screenOrientation 属性强制指定方向,否则会覆盖插件的设置。
  • portraitAutoMode 行为: 在某些 Android 设备上,portraitAutoMode 可能无法支持 180 度反向旋转(即竖屏倒置)。如果你需要完全根据传感器在所有四个方向上自由旋转,请使用 fullAutoMode
0
likes
130
points
173
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for controlling screen orientation, supporting both Android and iOS platforms.一个用于控制屏幕方向的Flutter插件,支持Android和iOS平台。

Repository (GitHub)
View/report issues

Topics

#flutter-plugin #orientation #auto-orientation #screen-orientation #device-orientation

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_auto_orientation

Packages that implement flutter_auto_orientation