getNativeOrientation static method

Stream<CameraOrientations>? getNativeOrientation()

Implementation

static Stream<CameraOrientations>? getNativeOrientation() {
  _orientationStream ??= _orientationChannel
      .receiveBroadcastStream('orientationChannel')
      .transform(StreamTransformer<dynamic, CameraOrientations>.fromHandlers(
          handleData: (data, sink) {
    CameraOrientations? newOrientation;
    switch (data) {
      case 'LANDSCAPE_LEFT':
        newOrientation = CameraOrientations.landscape_left;
        break;
      case 'LANDSCAPE_RIGHT':
        newOrientation = CameraOrientations.landscape_right;
        break;
      case 'PORTRAIT_UP':
        newOrientation = CameraOrientations.portrait_up;
        break;
      case 'PORTRAIT_DOWN':
        newOrientation = CameraOrientations.portrait_down;
        break;
      default:
    }
    sink.add(newOrientation!);
  }));
  return _orientationStream;
}