Device Orientation Detector

A Flutter plugin that detects device orientation changes using native Android & iOS sensorsβ€”even when the app is locked to portrait mode! πŸš€

✨ Features

βœ… Detects portrait & landscape mode using accelerometer & motion sensors.
βœ… Works even when screen rotation is locked.
βœ… Lightweight & efficientβ€”doesn't drain battery.
βœ… No special permissions required on Android or iOS.

πŸ“¦ Installation

Add this to your pubspec.yaml:

dependencies:
  device_orientation_detector: ^1.0.3

Then, run:

flutter pub get

πŸš€ Usage

import 'package:device_orientation_detector/device_orientation_detector.dart';

void main() {
  DeviceOrientationDetector().onOrientationChanged.listen((orientation) {
    print('Orientation: $orientation'); // "portrait" or "landscape"
  });
}

πŸ“± Platform Support

βœ” Android (Uses SensorManager)
βœ” iOS (Uses CoreMotion)

πŸ› οΈ How It Works

  • On Android, it uses the accelerometer sensor to determine the device's tilt.
  • On iOS, it uses CoreMotion to read the device's attitude and detect orientation.
  • Even when screen rotation is locked, this plugin detects orientation changes.

πŸ“ License

This project is licensed under the MIT License. See the LICENSE file for details.