setOrientationLandscape static method

Future<bool> setOrientationLandscape()

Only works on Android and iOS return false if current orientation is landscape return true if current orientation is portrait and after this API call finished, the orientation becomes landscape. return false if can't change orientation.

Implementation

static Future<bool> setOrientationLandscape() async {
  if (isDesktop()) return Future.value(false);
  bool? changed = await _channel.invokeMethod("setOrientationLandscape");
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft]);
  return Future.value(changed);
}