Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save shishirthedev/50a50f7dfb1237286e9942124bc02b69 to your computer and use it in GitHub Desktop.
Save shishirthedev/50a50f7dfb1237286e9942124bc02b69 to your computer and use it in GitHub Desktop.
Way 01:
---------------------------------------------------------
import 'package:flutter/services.dart';
void main() {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp,DeviceOrientation.portraitDown])
.then((_) {
runApp(MyApp());
});
}
{ Note: The 'setPreferredOrientations' method returns a Future object. that's why you
shall wait until it's available and then move on with the application. Hence,
there shall be used 'then' method }
Way 02:
---------------------------------------------------------
For Android:
Open android/app/src/main/AndroidManifest.xml and add
android:screenOrientation="portrait"
in your Main Activity
For iOS:
Open your project with xcode and restrict orientation for Potrait mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment