Search packages, repositories and app categories

Package detailsv2.3.1

auto_orientation

Set the device orientation programmatically for iOS and Android

AndroidiOS
30-day downloads
5.5K
Likes
88
Pub points
130

Install package

flutter pub add auto_orientation

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The auto_orientation package enables programmatic control of device screen orientation on both Android and iOS. It allows developers to lock or unlock the screen orientation dynamically during runtime, ensuring optimal user experience across different app states. This is particularly useful in apps requiring consistent orientation for specific views, such as video players or games. The package integrates seamlessly with Flutter and supports both landscape and portrait modes. It works by leveraging native platform APIs through platform channels.

Use cases

  • Video playback with fixed orientation
  • Games requiring locked screen orientation
  • Forms or UIs that need consistent layout
  • Cross-platform orientation management
  • Dynamic orientation changes based on content

Key features

  • Programmatically set orientation
  • Supports Android and iOS
  • Locks/unlocks orientation at runtime
  • Minimal boilerplate
  • Uses native platform channels

Suitable for

  • Apps needing dynamic orientation control
  • Developers targeting both iOS and Android
  • UI-heavy applications
  • Media or gaming apps
  • Responsive layouts requiring orientation consistency

Considerations

  • Requires appropriate permissions on some devices
  • May conflict with system-level orientation settings
  • Not suitable for all use cases due to platform restrictions
  • Limited to supported orientations
  • Behavior may vary slightly between platforms

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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

Categories

Source repository

Projects using this package