onDeviceOrientationChanged method

  1. @override
Stream<DeviceOrientationChangedEvent> onDeviceOrientationChanged()

The ui orientation changed.

Implementations for this:

  • Should support all 4 orientations.

Implementation

@override
Stream<DeviceOrientationChangedEvent> onDeviceOrientationChanged() {
  final web.ScreenOrientation orientation = window.screen.orientation;

  // Create an initial orientation event that emits the device orientation
  // as soon as subscribed to this stream.
  final web.Event initialOrientationEvent = web.Event('change');

  return orientationOnChangeProvider
      .forTarget(orientation)
      .startWith(initialOrientationEvent)
      .map(
    (web.Event _) {
      final DeviceOrientation deviceOrientation = _cameraService
          .mapOrientationTypeToDeviceOrientation(orientation.type);
      return DeviceOrientationChangedEvent(deviceOrientation);
    },
  );
}