auto_orientation_v2 2.3.7 copy "auto_orientation_v2: ^2.3.7" to clipboard
auto_orientation_v2: ^2.3.7 copied to clipboard

Set the device orientation programmatically for iOS and Android

auto_orientation #

A Flutter plugin to programmatically control device orientation on iOS and Android.
This package is an improved version of the original:
➡️ https://pub.dev/packages/auto_orientation


🚀 Features #

  • Instantly switch between Portrait, Landscape, and Auto modes.
  • No need to manually call SystemChrome.setPreferredOrientations.
  • Supports forceSensor on Android (overrides user's rotation settings, similar to YouTube fullscreen).
  • Ideal for video players, games, reading apps, and custom UI scenarios.

📦 Installation #

Add this to your pubspec.yaml:

dependencies:
  auto_orientation: ^<latest-version>

Import the package:

import 'package:auto_orientation/auto_orientation.dart';

📲 Usage #

🎞 Landscape Modes #

AutoOrientation.landscapeLeftMode();
AutoOrientation.landscapeRightMode();

📱 Portrait Modes #

AutoOrientation.portraitUpMode();
AutoOrientation.portraitDownMode(); // may not work on some devices

🧭 Auto Modes (Android Only) #

Follow device/user rotation preferences:

AutoOrientation.portraitAutoMode();
AutoOrientation.landscapeAutoMode();

Force sensor-based orientation (ignore user rotation preference):

AutoOrientation.portraitAutoMode(forceSensor: true);
AutoOrientation.landscapeAutoMode(forceSensor: true);

🔄 Full Auto Mode #

Allow all orientations:

AutoOrientation.fullAutoMode();

❗ Important Notes #

  • Do NOT call SystemChrome.setPreferredOrientations manually. The plugin manages orientation internally to avoid Android auto-rotation issues.

📘 Example #

A common use case: Flutter video player fullscreen.

@override
void initState() {
  super.initState();
  AutoOrientation.landscapeRightMode(); // switch to fullscreen landscape
}

@override
void dispose() {
  AutoOrientation.portraitUpMode(); // revert to portrait when closed
  super.dispose();
}

More examples are available inside the example/ folder.


📄 License #

MIT License © 2025


5
likes
140
points
2.38k
downloads

Publisher

verified publisherrizkyghofur.blogspot.com

Weekly Downloads

Set the device orientation programmatically for iOS and Android

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on auto_orientation_v2

Packages that implement auto_orientation_v2