N

native_device_orientation_aurora

This is a plugin project that allows for getting the native device orientation.

RU | EN

native_device_orientation_aurora

Original Readme.

Description

native_device_orientation_aurora is the Aurora OS implementation of the native_device_orientation plugin, which enables Flutter applications to accurately determine the device's physical orientation using native sensors or UI orientation data.

Quickstart: Basic Usage Example

import 'package:native_device_orientation/native_device_orientation.dart';

// Using the reader widget
NativeDeviceOrientationReader(
  builder: (context) {
    final orientation = NativeDeviceOrientationReader.orientation(context);
    return Text('Orientation: $orientation');
  },
);

// Alternatively, listen to orientation changes directly
final communicator = NativeDeviceOrientationCommunicator();
communicator.onOrientationChanged(useSensor: true).listen((orientation) {
  print('Orientation changed: $orientation');
});

// Stop orientation tracking when no longer needed
communicator.cancel();

Features

  • Detects device orientation using both UI and hardware sensors
  • Distinguishes between landscape left/right and portrait up/down
  • Provides widgets and direct API access for orientation info
  • Supports both polling and stream-based (event-driven) usage

Important Notes

  • UI-based orientation (useSensor: false): Uses QScreen which reflects compositor properties, not physical device position. In the current Aurora OS implementation, this method always returns portraitUp regardless of the actual device orientation. This method is not recommended for use.

  • Sensor-based orientation (useSensor: true): Uses hardware sensors (QOrientationSensor) to detect the actual physical device orientation. This is the only recommended approach for accurate orientation detection on Aurora OS.

  • Resource management: Always call cancel() on the communicator or properly dispose of widgets to stop orientation tracking when it's no longer needed to conserve battery life.


Contents

Installation and build

pubspec.yaml

dependencies:
  native_device_orientation: ^2.0.3
  native_device_orientation_aurora:
    git:
      url: https://developer.auroraos.ru/git/flutter/flutter-community-plugins/native_device_orientation_aurora.git

*main.cpp

#include <flutter/flutter_compatibility_qt.h>

int main(int argc, char *argv[]) {
    ...
    aurora::EnableQtCompatibility();
    ...
}

Compatibility

The application has been working correctly since the 5.0.0 version of the Aurora OS.

Terms of Use and Participation

The source code of the project is provided under the license, that allows it to be used in third-party applications.

To participate in the development of the project, please read the contributor agreement. If you plan to contribute your own source code to the project, you will need to accept the CLA agreement.

For information about contributors see AUTHORS.

Code of conduct is a current set of rules of the Open Mobile Platform which informs you how we expect the members of the community will interact while contributing and communicating.