setOrientationPortrait function

void setOrientationPortrait()

Locks the screen orientation to portrait mode.

  • Allows only portraitUp and portraitDown.
  • Useful for social apps, messaging apps, or reading content.

Example Usage:

setOrientationPortrait();

Implementation

void setOrientationPortrait() {
  SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitDown,
    DeviceOrientation.portraitUp,
  ]);
}